Truncatable primes: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added an END statement that a cut and paste missed. -- ~~~~ |
→{{header|Perl 6}}: prime tester was technically incorrect on 2, though we never test even numbers here |
||
Line 1,096: | Line 1,096: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
<lang perl6>my @primes := 2, 3, 5, -> $p { ($p+2, $p+4 ... &prime)[*-1] } ... *; |
<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) { |
sub prime($i) { @isprime[$i] //= $i %% none @primes ...^ * > sqrt $i } |
||
sub ltp { |
sub ltp { |