Smarandache-Wellin primes: Difference between revisions
m
→{{header|Raku}}: Fix typos
(Realize in F#) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: Fix typos) |
||
Line 448:
my @primes = (^∞).grep: &is-prime;
my @Smarandache-
sink @Smarandache-
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-
say ordinal-digit(++$,:u).fmt("%4s") ~ $_ for (^∞).hyper(:4batch).map({
next unless (my $sw = @Smarandache-
sprintf ": Index: %4d, Last prime: %5d, %s", $_, @primes[$_], $sw.&abbr
})[^8];
say "\nSmarandache-
say ordinal-digit(++$,:u).fmt("%4s") ~ $_ for (^∞).hyper(:8batch).map({
next unless (my $sw = @Smarandache-
sprintf ": Index: %4d, %s", $_, $sw
})[^20];</syntaxhighlight>
{{out}}
<pre>Smarandache-
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-
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.
|