Truncatable primes: Difference between revisions

→‎{{header|Perl 6}}: avoid X which is slow in rakudo, and this matches the rtp solution better anyway
(→‎{{header|Perl 6}}: prime tester was technically incorrect on 2, though we never test even numbers here)
(→‎{{header|Perl 6}}: avoid X which is slow in rakudo, and this matches the rtp solution better anyway)
Line 1,100:
 
sub ltp {
for (9...1) X (9...1) X (9...1) X (9...1) X (9...1) X (9,7,3) -> $a,$b,$c,$d,$e,$f {
for 9...1 -> $b {
my @x := [\+] $f, $e, $d, $c, $b, $a Z* (1,10,100 ... *);
return @x[*-1] if prime @x[0]for and prime @x[9...1] and prime-> @x[2]$c and{
for 9...1 -> $d {
prime @x[3] and prime @x[4] and prime @x[5];
for 9...1 -> $e {
for 9,7,3 -> $f {
my @x := [\+] $f, $e, $d, $c, $b, $a Z* (1,10,100 ... *);
return @x[*-1] if not grep {not prime $^n}, @x;
}
}
}
}
}
}
}
Anonymous user