A modest improvement in speed may be obtained if one implements the wheel.
For example (the modulus is relatively cheap in perl):
sub primes { my $n = shift; return if $n < 2; my @primes = (2); I: for my $i (3 .. $n) { next unless 0x208a28aa & (1 << $i % 30); my $sqrt = int sqrt $i; for my $p (@primes) { next I unless $i % $p; last if $p > $sqrt; } push @primes, $i; } return @primes }
In reply to Re^3: Number functions I have lying around
by Anonymous Monk
in thread Number functions I have lying around
by Lady_Aleena
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |