Cuban primes: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) →{{header|Perl 6}}: Faster prime testing, big speed boost |
|||
Line 899: | Line 899: | ||
===The task (k == 1)=== |
===The task (k == 1)=== |
||
Not the most efficient, but concise, and good enough for this task. |
Not the most efficient, but concise, and good enough for this task. Use the ntheory library for prime testing; gets it down to around 20 seconds. |
||
<lang perl6> |
<lang perl6>use Lingua::EN::Numbers; |
||
use ntheory:from<Perl5> <:all>; |
|||
my @cubans = lazy (1..Inf |
my @cubans = lazy (1..Inf).map({ ($_+1)³ - .³ }).grep: *.&is_prime; |
||
put @cubans[^200]».&comma».fmt("%9s").rotor(10).join: "\n"; |
put @cubans[^200]».&comma».fmt("%9s").rotor(10).join: "\n"; |