in reply to Re: Can't call method "forprimes"
in thread Can't call method "forprimes"
use Modern::Perl; use Sub::Signatures; use ntheory 'primes'; use bigint; print join "*", sieve3( 12, 1, 10, 10, 100 ); sub sieve3 ( $n, $c, $k, $l, $p ) { my %candidates = map { $_ => $n * ( $k + $_ ) + $c } ( 0 .. $l ); foreach my $prime ( @{primes $p} ) { foreach my $candidate ( keys %candidates ) { delete $candidates{$candidate} if defined $candidates{$candidate} && $candidates{$can +didate} % $prime == 0; } } return sort { $a <=> $b } keys %candidates; }
|
|---|