Erdős-Nicolas numbers: Difference between revisions

Added XPL0 example.
(Added C++ solution)
(Added XPL0 example.)
Line 300:
714240 from 113
1571328 from 115
</pre>
 
=={{header|XPL0}}==
Translation of Algol 68 and C++.
<syntaxhighlight lang "XPL0">def Max = 2_000_000;
int DSum(Max+1), DCount(Max+1);
int I, J;
[for I:= 0 to Max do
[DSum(I):= 1;
DCount(I):= 1;
];
Format(8, 0);
for I:= 2 to Max do
[J:= I+I;
while J <= Max do
[if DSum(J) = J then
[RlOut(0, float(J));
Text(0, " equals the sum of its first ");
IntOut(0, DCount(J));
Text(0, " divisors^j^m");
];
DSum(J):= DSum(J)+I;
DCount(J):= DCount(J)+1;
J:= J+I;
]
]
]</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
</pre>
297

edits