Ormiston pairs: Difference between revisions
→{{header|Free Pascal}}: checking mod 18 =0 is faster.
m (uups sort entries) |
(→{{header|Free Pascal}}: checking mod 18 =0 is faster.) |
||
Line 412:
=={{header|Pascal}}==
==={{header|Free Pascal}}===
//update the digits by adding difference.// Using MOD 18 = 0 and convert is faster.
<syntaxhighlight lang=pascal>
program Ormiston;
Line 533:
type
td10_UsedDgts2 = array[0..
tpd10_UsedDgts2 = ^td10_UsedDgts2;
end;▼
var
p_zero : tDigits10;// faster than fillchar
begin▼
dec(i);▼
procedure OutIn(cnt,p1,p2:NativeInt);
Line 575 ⟶ 552:
end;
var
begin
begin
▲ i := 0;
repeat
r := p DIV 10;
p := r;
until r = 0;
Line 594 ⟶ 566:
end;
function CheckOrmiston(const d1,d2:tpd10_UsedDgts2):boolean;inline;▼
// checking four digits at once.Ord to circumvent conditional jumps
if dgt >= 10 then▼
▲function CheckOrmiston(d1,d2:tpd10_UsedDgts2):boolean;inline;
begin
// result := (d1^[0]=d2^[0]) AND (d1^[1]=d2^[1]) AND (d1^[2]=d2^[2]);
end;
Line 639 ⟶ 576:
pSieve : tpPrimes;
T1,T0: TDateTime;
{$align 16}
p1,p2 :tDigits10;
pr,pr_before,
Line 650 ⟶ 588:
pSieve := @PrimeSieve[0];
pr_before := 2;
pr := pr_before;
prLimit := 100*1000;
Line 660 ⟶ 598:
if pr > limit then
BREAK;
begin
Convert2Digits10(pr_before,p2);
if
▲ begin
OutIn(cnt,pr_before,pr);
end;
p1 := p2;
Line 688 ⟶ 630:
34,901 Ormiston pairs before 100,000,000
Real time: 0.
@home 1E10
// Limit= 10*1000*1000*1000;
time for sieving 00:17.
....
34,901 Ormiston pairs before 100,000,000
326,926 Ormiston pairs before 1,000,000,000
3,037,903 Ormiston pairs before 10,000,000,000
real
</pre>
=={{header|Phix}}==
{{trans|Wren}}
|