Abigail <(E-Mail Removed)> wrote in comp.lang.perl.misc:

> (E-Mail Removed) ((E-Mail Removed)) wrote on MMMMCMLII

> September MCMXCIII in

> <URL:news:(E-Mail Removed) legroups.com>:

> @@ How can I improve my code?... faster, better style, proper programming

> @@ techniques, better algorithm? Thanks!

>

> A better algorith beats everything else.

>

> If you want to generate prime numbers starting from 1, sieves are your

> best option. They have been your best option since antiquity.

>

> Here's an example of a sieve:

>

>

> #!/opt/perl/bin/perl -l

>

> # A sieve based on base 6. Only possible primes are those numbers p

> # for which p mod 6 == 1, or p mod 6 == 5.

> #

> # Let n = 6 * k + l (0 <= l < 6). Then the bit b associated with n is

> # b = 2 * k + [undef, 0, undef, undef, undef, 1] -> [l]

> # In reverse, given a bit b, the corresponding number n is

> # n = 6 * int (b / 2) + [1, 5] -> [b % 2].
[snip

Ah, I remember that. You developed it from a modest beginning (base 10,

if memory serves) to this form in steps, posting and discussing intermediate

implementations on clpm. That was fun.

Anno