in reply to Can't call method "forprimes"
Hello pvfki,
Your script has a number of problems:
I think the following code is what you’re looking for:
use warnings; use strict; use ntheory 'forprimes'; use bigint; my $n = 12; my $c = 1; my $k = 10; my $l = 10; my $p = 100; my @candidates = (0 .. $l); my $remove; sieve2(); sub sieve2 { forprimes { for my $i (0 .. $l) { if (($n * ($k + $i) + $c) % $_ == 0) { $remove = $i; @candidates = grep { $_ != $remove } @candidates; } } } $p; print join("\n", @candidates),"\n"; }
Output:
16:58 >perl 2012_SoPW.pl 3 5 6 9 10 16:58 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't call method "forprimes"
by holli (Abbot) on Jul 15, 2019 at 08:14 UTC |