Anonymous user
Deceptive numbers: Difference between revisions
m
→{{header|Free Pascal}}: No multiple of 5 like Nigel mentioned
m (→{{header|Free Pascal}}: only checking odd divisors halving timing) |
m (→{{header|Free Pascal}}: No multiple of 5 like Nigel mentioned) |
||
Line 115:
==={{header|Free Pascal}}===
Brute force, not using gmp. Runtime ~ n^2.<BR>
Like Wren,et alias only checking odd divisors
Like Nigel said, no multiple of 5.
<lang pascal>program DeceptiveNumbers;
{$IfDef FPC} {$Optimization ON,ALL} {$ENDIF}
Line 130 ⟶ 131:
tmyUint64 = array[0..Limit DIV RepInitLen+1] of Uint64;
var
{$Align 32}
K: tmyUint64;
{$Align 32}
MaxKIdx : Int32;
Line 201 ⟶ 204:
end;
const
NextNotMulOF35 : array[0..7] of byte = (6,4,2,4,2,4,6,2);
var
i
BEGIN
fillchar(K,SizeOF(K),#0);
MaxKIdx:= 0;
cnt := 0;
i :=
idx35 := 0;
inc(i,
BREAK;
idx35 := (idx35+1) AND 7;
if isprime(i) then
continue;
ExtendRep(k,i-1);
Line 218 ⟶ 226:
inc(cnt);
write(i:6,',');
if cnt Mod 10 = 0 then
writeln;
end;
{$IfDef Windows}
readln;
Line 228 ⟶ 237:
{{out|@TIO.RUN}}
<pre>
Real time: 1.
91, 259, 451, 481, 703, 1729, 2821, 2981, 3367, 4141,
4187, 5461, 6533, 6541, 6601, 7471, 7777, 8149, 8401, 8911,
Line 235 ⟶ 245:
45527, 46657, 48433, 50851, 50881, 52633, 54913, 57181, 63139, 63973,
65311, 66991, 67861, 68101, 75361, 79003, 82513, 83119, 94139, 95161,
97273, 97681,</pre>
=={{header|Perl}}==
|