Difference between revisions of "Sieve of Sundaram"
m (→Generalization for prime finding) |
m (→Generalization for prime finding) |
||
Line 93: | Line 93: | ||
\end{array}</cmath> | \end{array}</cmath> | ||
− | The table leaves <math>30ab</math> off each to save space. the general rule, for modulus <math>m</math>, with remainders <math>c,d</math> is: <cmath>m(mab+da+cb+\lfloor cd\over m\rfloor)+(cd\bmod m)</cmath> in general | + | The table leaves <math>30ab</math> off each to save space. the general rule, for modulus <math>m</math>, with remainders <math>c,d</math> is: <cmath>m(mab+da+cb+\lfloor {cd\over m}\rfloor)+(cd\bmod m)</cmath> in general. |
+ | |||
Revision as of 14:31, 27 February 2020
Contents
Description
The Sieve of Sundaram is a sieve for a range of odd prime numbers.The sieve starts out listing the natural numbers to like the following example ()
Step 2
Then it finds all numbers of form ( fancy way of saying start at and increase by , for each not already eliminated ) and eliminates them (empty cells):
Step 3
Double each number and add one:
Basis
The basis of the algorithm is that for (without loss of generality, as the form we double and add 1 to is made up of commutative operations); with both factors nontrivial.
Optimization
The equivalent in Step 2 above, of the Sieve of Eratosthenes starting the at the next prime squared, is starting at for next index
Generalization for prime finding
Looking close, if you know modular arithmetic, you'll note the remainder 1 forms the modular multiplicative group modulo 2. This generalizes to the modular multiplicative group mod any natural number( with loss of factors in the prime list). This generalization either needs copies of the same numbers ( one for each class), or (triangle numbers) colors . The class of remainder 1, is the only class where variable must stay nonzero to introduce a nontrivial factor by default ( negative representatives increase variable value required by 1). Modulo 30 is sketched out below (8 classes):
The table leaves off each to save space. the general rule, for modulus , with remainders is: in general.