Truncatable primes: Difference between revisions
Content deleted Content added
Line 252: | Line 252: | ||
sub trunc_prime ($filter, $limit) { |
sub trunc_prime ($filter, $limit) { |
||
my $odd = $limit + ($limit % 2 ?? 0 !! 1); |
my $odd = $limit + ($limit % 2 ?? 0 !! 1); |
||
loop (my $loop = $odd; $loop -= 2; $loop <= 2) { |
loop (my $loop = $odd; $loop -= 2; $loop <= 2 ) { |
||
next if $loop ~~ /0/; # No zeros allowed |
next if $loop ~~ /0/; # No zeros allowed |
||
my $this = $loop; |
my $this = $loop; |
||
my |
my $answer; |
||
while $this.&isprime { |
while $this.&isprime { |
||
push @these, $this; |
|||
$this.=subst($filter, ''); |
$this.=subst($filter, ''); |
||
$answer = $loop if $this eq ''; |
$answer = $loop if $this eq ''; |
||
} |
} |
||
return |
return $answer and last if $answer; |
||
} |
} |
||
} |
} |