Cuban primes: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Faster prime testing, big speed boost)
Line 899:
 
===The task (k == 1)===
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>subuse comma { $^i.flip.comb(3).join(',').flip }Lingua::EN::Numbers;
use ntheory:from<Perl5> <:all>;
 
my @cubans = lazy (1..Inf).hyper(:8degree).map({ ($_+1)³ - .³ }).grep: *.is-prime&is_prime;
 
put @cubans[^200]».&comma».fmt("%9s").rotor(10).join: "\n";