Ormiston pairs: Difference between revisions

Added XPL0 example.
(Added Algol 68)
(Added XPL0 example.)
Line 233:
3,722 Ormiston pairs before 10,000,000
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">func IsPrime(N); \Return 'true' if N is prime
int N, I;
[if N <= 2 then return N = 2;
if (N&1) = 0 then \even >2\ return false;
for I:= 3 to sqrt(N) do
[if rem(N/I) = 0 then return false;
I:= I+1;
];
return true;
];
 
func GetSig(N); \Return signature of N
\A "signature" is the count of each digit in N packed into a 32-bit word
int N, Sig;
[Sig:= 0;
repeat N:= N/10;
Sig:= Sig + 1<<(rem(0)*3);
until N = 0;
return Sig;
];
 
int Cnt, N, N0, Sig, Sig0;
[Cnt:= 0; N0:= 0; Sig0:= 0; N:= 3;
Format(6, 0);
loop [if IsPrime(N) then
[Sig:= GetSig(N);
if Sig = Sig0 then
[Cnt:= Cnt+1;
if Cnt <= 30 then
[RlOut(0, float(N0)); RlOut(0, float(N));
if rem(Cnt/3) = 0 then CrLf(0) else Text(0, " ");
];
];
Sig0:= Sig;
N0:= N;
];
if N = 1_000_000-1 then
[Text(0, "^m^jOrmiston pairs up to one million: ");
IntOut(0, Cnt);
];
if N = 10_000_000-1 then
[Text(0, "^m^jOrmiston pairs up to ten million: ");
IntOut(0, Cnt);
quit;
];
N:= N+2;
];
]</syntaxhighlight>
{{out}}
<pre>
1913 1931 18379 18397 19013 19031
25013 25031 34613 34631 35617 35671
35879 35897 36979 36997 37379 37397
37813 37831 40013 40031 40213 40231
40639 40693 45613 45631 48091 48109
49279 49297 51613 51631 55313 55331
56179 56197 56713 56731 58613 58631
63079 63097 63179 63197 64091 64109
65479 65497 66413 66431 74779 74797
75913 75931 76213 76231 76579 76597
 
Ormiston pairs up to one million: 382
Ormiston pairs up to ten million: 3722</pre>
295

edits