Substring primes: Difference between revisions

→‎{{header|Raku}}: Added Advanced / Stretch Goal solution
(→‎{{header|Raku}}: Added Raku solution)
(→‎{{header|Raku}}: Added Advanced / Stretch Goal solution)
Line 248:
<pre>
(2 3 5 7 23 37 53 73 373)</pre>
===Stretch Goal===
<lang perl6>my $prime-tests = 0;
my @non-primes;
sub spy-prime ($n) {
$prime-tests++;
my $is-p = $n.is-prime;
 
push @non-primes, $n unless $is-p;
return $is-p;
}
 
my @p = <2 3 5 7>;
 
say gather while @p {
.take for @p;
 
@p = ( @p X~ <3 7> ).grep: { !.ends-with(33|77) and .&spy-prime };
}
.say for :$prime-tests, :@non-primes;</lang>
{{out}}
<pre>
(2 3 5 7 23 37 53 73 373)
prime-tests => 11
non-primes => [27 57 237 537 737 3737]</pre>
 
=={{header|REXX}}==
256

edits