Pierpont primes: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 2,934:
{{libheader|Wren-fmt}}
The 3-smooth version. Just the first 250 - a tolerable 14 seconds or so on my machine.
<syntaxhighlight lang="ecmascriptwren">import "./big" for BigInt
import "./fmt" for Fmt
 
var pierpont = Fn.new { |n, first|
Line 3,015:
 
250th Pierpont prime of the second kind: 4111131172000956525894875083702271
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">func IsPrime(N); \Return 'true' if N is prime
int N, D;
[if N < 2 then return false;
if (N&1) = 0 then return N = 2;
if rem(N/3) = 0 then return N = 3;
D:= 5;
while D*D <= N do
[if rem(N/D) = 0 then return false;
D:= D+2;
if rem(N/D) = 0 then return false;
D:= D+4;
];
return true;
];
 
func Pierpont(N); \Return 'true' if N is a multiple of 2^U*3^V
int N;
[while (N&1) = 0 do N:= N>>1;
while N>1 do
[N:= N/3;
if rem(0) # 0 then return false;
];
return true;
];
 
int Kind, N, Count;
[Format(9, 0);
Kind:= 1;
repeat Count:= 0; N:= 2;
loop [if IsPrime(N) then
[if Pierpont(N-Kind) then
[Count:= Count+1;
RlOut(0, float(N));
if rem(Count/10) = 0 then CrLf(0);
if Count >= 50 then quit;
];
];
N:= N+1;
];
CrLf(0);
Kind:= -Kind;
until Kind = 1;
]</syntaxhighlight>
{{out}}
<pre>
2 3 5 7 13 17 19 37 73 97
109 163 193 257 433 487 577 769 1153 1297
1459 2593 2917 3457 3889 10369 12289 17497 18433 39367
52489 65537 139969 147457 209953 331777 472393 629857 746497 786433
839809 995329 1179649 1492993 1769473 1990657 2654209 5038849 5308417 8503057
 
2 3 5 7 11 17 23 31 47 53
71 107 127 191 383 431 647 863 971 1151
2591 4373 6143 6911 8191 8747 13121 15551 23327 27647
62207 73727 131071 139967 165887 294911 314927 442367 472391 497663
524287 786431 995327 1062881 2519423 10616831 17915903 18874367 25509167 30233087
 
</pre>
 
9,476

edits