Erdős-Nicolas numbers: Difference between revisions
Content added Content deleted
m (→{{header|Free Pascal}}: using fast prime decomposition less then 16 s til 1e8 on TIO.RUN.@home 7.2s) |
No edit summary |
||
Line 352: | Line 352: | ||
91963648 equals the sum of its first 142 divisors |
91963648 equals the sum of its first 142 divisors |
||
</pre> |
</pre> |
||
=={{header|Delphi}}== |
|||
{{works with|Delphi|6.0}} |
|||
{{libheader|SysUtils,StdCtrls}} |
|||
Translation from the C version |
|||
<syntaxhighlight lang="Delphi"> |
|||
const MaxNumber = 100000000; |
|||
var DSum: array [0..MaxNumber-1] of integer; |
|||
var DCount: array [0..MaxNumber-1] of integer; |
|||
procedure ShowErdosNicolasNumbers(Memo: TMemo); |
|||
var I,J: integer; |
|||
begin |
|||
for I:=0 to MaxNumber-1 do |
|||
begin |
|||
DSum[I]:=1; |
|||
DCount[I]:=1; |
|||
end; |
|||
for I:=2 to MaxNumber-1 do |
|||
begin |
|||
J:=I*2; |
|||
while J<MaxNumber do |
|||
begin |
|||
if dsum[J] = j then |
|||
begin |
|||
Memo.Lines.Add(Format('%8d equals the sum of its first %d divisors', [j, dcount[j]])); |
|||
end; |
|||
Inc(dsum[J],I); |
|||
Inc(DCount[J]); |
|||
Inc(J,I); |
|||
end; |
|||
end; |
|||
end; |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
24 equals the sum of its first 6 divisors |
|||
2016 equals the sum of its first 31 divisors |
|||
8190 equals the sum of its first 43 divisors |
|||
42336 equals the sum of its first 66 divisors |
|||
45864 equals the sum of its first 66 divisors |
|||
714240 equals the sum of its first 113 divisors |
|||
392448 equals the sum of its first 68 divisors |
|||
1571328 equals the sum of its first 115 divisors |
|||
61900800 equals the sum of its first 280 divisors |
|||
91963648 equals the sum of its first 142 divisors |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |