Wagstaff primes: Difference between revisions

Added XPL0 example.
(Wagstaff primes in BASIC-256)
(Added XPL0 example.)
Line 611:
12391 (341 secs)
14479 (593 secs)
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">func IsPrime(N); \Return 'true' if N is prime
real N; int I;
[if N <= 2. then return N = 2.;
if Mod(N, 2.) = 0. then \even\ return false;
for I:= 3 to fix(sqrt(N)) do
[if Mod(N, float(I)) = 0. then return false;
I:= I+1;
];
return true;
];
 
real P, Q; int C;
[P:= 2.; C:= 0;
Format(1, 0);
repeat if IsPrime(P) then
[Q:= Pow(2., P) + 1.;
if Mod(Q, 3.) = 0. and IsPrime(Q/3.) then
[Text(0, "(2^^");
RlOut(0, P);
Text(0, " + 1)/3 = ");
RlOut(0, Q/3.);
CrLf(0);
C:= C+1;
];
];
P:= P+1.;
until C >= 10;
]</syntaxhighlight>
{{out}}
<pre>
(2^3 + 1)/3 = 3
(2^5 + 1)/3 = 11
(2^7 + 1)/3 = 43
(2^11 + 1)/3 = 683
(2^13 + 1)/3 = 2731
(2^17 + 1)/3 = 43691
(2^19 + 1)/3 = 174763
(2^23 + 1)/3 = 2796203
(2^31 + 1)/3 = 715827883
(2^43 + 1)/3 = 2932031007403
</pre>
295

edits