Truncatable primes: Difference between revisions

→‎{{header|Perl 6}}: avoid recalculating sqrt
(→‎{{header|Perl 6}}: avoid X which is slow in rakudo, and this matches the rtp solution better anyway)
(→‎{{header|Perl 6}}: avoid recalculating sqrt)
Line 1,097:
<lang perl6>my @primes := 2, 3, 5, -> $p { ($p+2, $p+4 ... &prime)[*-1] } ... *;
my @isprime = False,False; # 0 and 1 are not primes by definition
sub prime($i) { @isprime[$i] //= ($i %% none @primes ...^ * > sqrt$_ given $i.sqrt.floor) }
 
sub ltp {
Anonymous user