Smarandache-Wellin primes: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: display as ordinals) |
SqrtNegInf (talk | contribs) (→{{header|Perl}}: added derived primes) |
||
Line 504: | Line 504: | ||
{{libheader|ntheory}} |
{{libheader|ntheory}} |
||
<syntaxhighlight lang="perl" line> |
<syntaxhighlight lang="perl" line> |
||
use |
use v5.36; |
||
use warnings; |
|||
use ntheory <is_prime next_prime>; |
use ntheory <is_prime next_prime>; |
||
use Lingua::EN::Numbers::Ordinate 'ordinate'; |
use Lingua::EN::Numbers::Ordinate 'ordinate'; |
||
Line 517: | Line 516: | ||
$n .= $p; |
$n .= $p; |
||
$i++; |
$i++; |
||
(++$nth and |
(++$nth and printf("%s: Index:%5d Last prime:%6d S-W: %s\n", ordinate $nth, $i, $p, abbr $n)) if is_prime $n; |
||
} until $nth == 8; |
} until $nth == 8; |
||
sub derived ($n) { |
|||
my %digits; |
|||
$digits{$_}++ for split '', $n; |
|||
join '', map { $digits{$_} // 0 } 0..9; |
|||
} |
|||
print "\nSmarandache-Wellen derived primes:\n"; |
|||
($p, $i, $nth, $n) = (1, -1, 0, ''); |
|||
do { |
|||
$i++; |
|||
$n .= ($p = next_prime($p)); |
|||
++$nth and printf "%4s: Index:%5d %s\n", ordinate $nth, $i, derived $n if is_prime derived $n; |
|||
} until $nth == 20; |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 531: | Line 544: | ||
7th: Index: 434 Last prime: 3037 S-W: 23571113171923293137..30013011301930233037 (1543 digits) |
7th: Index: 434 Last prime: 3037 S-W: 23571113171923293137..30013011301930233037 (1543 digits) |
||
8th: Index: 1428 Last prime: 11927 S-W: 23571113171923293137..11903119091192311927 (5719 digits) |
8th: Index: 1428 Last prime: 11927 S-W: 23571113171923293137..11903119091192311927 (5719 digits) |
||
Smarandache-Wellen derived primes: |
|||
1st: Index: 31 4194123321127 |
|||
2nd: Index: 71 547233879626521 |
|||
3rd: Index: 72 547233979727521 |
|||
4th: Index: 133 13672766322929571043 |
|||
5th: Index: 224 3916856106393739943689 |
|||
6th: Index: 302 462696313560586013558131 |
|||
7th: Index: 308 532727113760586013758133 |
|||
8th: Index: 362 6430314317473636515467149 |
|||
9th: Index: 461 8734722823685889120488197 |
|||
10th: Index: 489 9035923128899919621189209 |
|||
11th: Index: 494 9036023329699969621389211 |
|||
12th: Index: 521 9337023533410210710923191219 |
|||
13th: Index: 537 94374237357103109113243102223 |
|||
14th: Index: 623 117416265406198131121272110263 |
|||
15th: Index: 720 141459282456260193137317129313 |
|||
16th: Index: 737 144466284461264224139325131317 |
|||
17th: Index: 789 156483290479273277162351153339 |
|||
18th: Index: 851 164518312512286294233375158359 |
|||
19th: Index: 1086 208614364610327343341589284471 |
|||
20th: Index: 1187 229667386663354357356628334581 |
|||
</pre> |
</pre> |
||