Smarandache-Wellin primes: Difference between revisions
m
→{{header|Raku}}: Include ordinals, show more derived SW primes
Thundergnat (talk | contribs) m (→{{header|Raku}}: Whoops, overlooked zero) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: Include ordinals, show more derived SW primes) |
||
Line 33:
=={{header|Raku}}==
The first seven Smarandache-Wellin primes are found in a few seconds on my system. The eighth adds over five minutes to the run time.
<syntaxhighlight lang="raku" line>
my @primes = (^∞).grep: &is-prime;
my @Smarandache-Whellen = [\~] @primes;
Line 43 ⟶ 45:
sub abbr ($_) { .chars < 41 ?? $_ !! .substr(0,20) ~ '…' ~ .substr(*-20) ~ " ({.chars} digits)" }
say "Smarandache-Whellen primes:
say ordinal-digit(++$,:u).fmt("%4s") ~ $_ for (^∞).hyper(:4batch).map({
next unless (my $sw = @Smarandache-Whellen[$_]).is-prime;
sprintf ": Index: %4d, Last prime: %5d, %s
})[^8];
say "\nSmarandache-Whellen derived primes:
say ordinal-digit(++$,:u).fmt("%4s") ~ $_ for (^∞).hyper(:8batch).map({
next unless (my $sw = @Smarandache-Whellen[$_].&derived).is-prime;
sprintf ": Index: %4d, %s
})[^
{{out}}
<pre>Smarandache-Whellen primes:
Smarandache-Whellen derived primes:
11ᵗʰ: Index: 494, 9036023329699969621389211
12ᵗʰ: Index: 521, 9337023533410210710923191219
13ᵗʰ: Index: 537, 94374237357103109113243102223
14ᵗʰ: Index: 623, 117416265406198131121272110263
15ᵗʰ: Index: 720, 141459282456260193137317129313
16ᵗʰ: Index: 737, 144466284461264224139325131317
17ᵗʰ: Index: 789, 156483290479273277162351153339
18ᵗʰ: Index: 851, 164518312512286294233375158359
19ᵗʰ: Index: 1086, 208614364610327343341589284471
20ᵗʰ: Index: 1187, 229667386663354357356628334581</pre>
=={{header|Wren}}==
|