Smarandache-Wellin primes: Difference between revisions

m
(Realize in F#)
m (→‎{{header|Raku}}: Fix typos)
Line 448:
my @primes = (^∞).grep: &is-prime;
 
my @Smarandache-WhellenWellen = [\~] @primes;
 
sink @Smarandache-WhellenWellen[1500]; # pre-reify for concurrency
 
sub derived ($n) { my %digits = $n.comb.Bag; (0..9).map({ %digits{$_} // 0 }).join }
Line 456:
sub abbr ($_) { .chars < 41 ?? $_ !! .substr(0,20) ~ '…' ~ .substr(*-20) ~ " ({.chars} digits)" }
 
say "Smarandache-WhellenWellen primes:";
say ordinal-digit(++$,:u).fmt("%4s") ~ $_ for (^∞).hyper(:4batch).map({
next unless (my $sw = @Smarandache-WhellenWellen[$_]).is-prime;
sprintf ": Index: %4d, Last prime: %5d, %s", $_, @primes[$_], $sw.&abbr
})[^8];
 
say "\nSmarandache-WhellenWellen derived primes:";
say ordinal-digit(++$,:u).fmt("%4s") ~ $_ for (^∞).hyper(:8batch).map({
next unless (my $sw = @Smarandache-WhellenWellen[$_].&derived).is-prime;
sprintf ": Index: %4d, %s", $_, $sw
})[^20];</syntaxhighlight>
{{out}}
<pre>Smarandache-WhellenWellen primes:
1ˢᵗ: Index: 0, Last prime: 2, 2
2ⁿᵈ: Index: 1, Last prime: 3, 23
Line 478:
8ᵗʰ: Index: 1428, Last prime: 11927, 23571113171923293137…11903119091192311927 (5719 digits)
 
Smarandache-WhellenWellen derived primes:
1ˢᵗ: Index: 31, 4194123321127
2ⁿᵈ: Index: 71, 547233879626521
Line 499:
19ᵗʰ: Index: 1086, 208614364610327343341589284471
20ᵗʰ: Index: 1187, 229667386663354357356628334581</pre>
 
=={{header|Ruby}}==
The first seven Smarandache-Wellin primes are found in about 12 seconds on my system. The eighth (not shown here) takes nine minutes.
10,327

edits