Fermat's Factorization Method - Sieve Improvement

Sieve Improvement

It is not necessary to compute all the square-roots of, nor even examine all the values for . Examine the tableau for :

a: 48433 48434 48435 48436
b2: 76572 173439 270308 367179
b: 276.7 416.5 519.9 605.9

One can quickly tell that none of these values of b2 are squares. Squares end with 0, 1, 4, 5, 9, or 16 modulo 20. The values repeat with each increase of by 10. For this example, adding '-17' mod 20 (or 3), produces 3, 4, 7, 8, 12, and 19 modulo 20 for these values. It is apparent that only the 4 from this list can be a square. Thus, must be 1 mod 20, which means that is 1 or 9 mod 10; it will produce a b2 which ends in 4 mod 20 and, if square, will end in 2 or 8 mod 10.

This can be performed with any modulus. Using the same ,

modulo 16: Squares are 0, 1, 4, or 9
N mod 16 is 5
so can only be 9
and must be 3 or 5 or 11 or 13 modulo 16
modulo 9: Squares are 0, 1, 4, or 7
N mod 9 is 7
so can only be 7
and must be 4 or 5 modulo 9

One generally chooses a power of a different prime for each modulus.

Given a sequence of a-values (start, end, and step) and a modulus, one can proceed thus:

FermatSieve(N, astart, aend, astep, modulus)
a ← astart
do modulus times:
b2 ← a*a - N
if b2 is a square, modulo modulus:
FermatSieve(N, a, aend, astep * modulus, NextModulus)
endif
a ← a + astep
enddo

But the recursion is stopped when few a-values remain; that is, when (aend-astart)/astep is small. Also, because a's step-size is constant, one can compute successive b2's with additions.

Read more about this topic:  Fermat's Factorization Method

Famous quotes containing the words sieve and/or improvement:

    They went to sea in a Sieve, they did,
    In a Sieve they went to sea:
    In spite of all their friends could say,
    On a winter’s morn, on a stormy day,
    Edward Lear (1812–1888)

    We are more thoroughly an enlightened people, with respect to our political interests, than perhaps any other under heaven. Every man among us reads, and is so easy in his circumstances as to have leisure for conversations of improvement and for acquiring information.
    Benjamin Franklin (1706–1790)