Wolstenholme numbers: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl}}: Also, won't run under 5.30) |
SqrtNegInf (talk | contribs) (→{{header|Perl}}: now runs correctly, and on older Perl) |
||
Line 392: | Line 392: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{incorrect|Perl|First four "primes" are not prime}} |
|||
{{libheader|ntheory}} |
{{libheader|ntheory}} |
||
<syntaxhighlight lang="perl" line> |
<syntaxhighlight lang="perl" line> |
||
Line 400: | Line 399: | ||
use Math::BigRat try => 'GMP'; |
use Math::BigRat try => 'GMP'; |
||
sub abbr |
sub abbr { my $d = shift; my $l = length $d; $l < 41 ? $d : substr($d,0,20) . '..' . substr($d,-20) . " ($l digits)" } |
||
my @W = Math::BigRat->new('1/1'); |
my @W = Math::BigRat->new('1/1'); |
||
Line 409: | Line 408: | ||
push @res, "\nPrime Wolstenholme numbers:"; |
push @res, "\nPrime Wolstenholme numbers:"; |
||
my($n,$c |
my($n,$c); |
||
do { printf "%5s: %s\n", ++$c, abbr $W[$n]->numerator() if is_prime $W[ |
do { printf "%5s: %s\n", ++$c, abbr $W[$n]->numerator() if is_prime $W[++$n]->numerator() } until $c == 15; |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 442: | Line 441: | ||
Prime Wolstenholme numbers: |
Prime Wolstenholme numbers: |
||
1: |
1: 5 |
||
2: |
2: 266681 |
||
3: |
3: 40799043101 |
||
4: |
4: 86364397717734821 |
||
5: |
5: 36190908596780862323..79995976006474252029 (104 digits) |
||
6: |
6: 33427988094524601237..48446489305085140033 (156 digits) |
||
7: |
7: 22812704758392002353..84405125167217413149 (218 digits) |
||
8: |
8: 28347687473208792918..45794572911130248059 (318 digits) |
||
9: |
9: 78440559440644426017..30422337523878698419 (520 digits) |
||
10: |
10: 22706893975121925531..02173859396183964989 (649 digits) |
||
11: |
11: 27310394808585898968..86311385662644388271 (935 digits) |
||
12: |
12: 13001072736642048751..08635832246554146071 (984 digits) |
||
13: |
13: 15086863305391456002..05367804007944918693 (1202 digits) |
||
14: |
14: 23541935187269979100..02324742766220468879 (1518 digits) |
||
15: |
15: 40306783143871607599..58901192511859288941 (1539 digits)</pre> |
||
</pre> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |