Idoneal numbers: Difference between revisions

Added XPL0 example.
(Idoneal numbers in various BASIC dialents (BASIC256 and Yabasic))
(Added XPL0 example.)
Line 511:
120 130 133 165 168 177 190 210 232 240 253 273 280
312 330 345 357 385 408 462 520 760 840 1320 1365 1848
</pre>
 
=={{header|XPL0}}==
Some optimizations borrowed from others.
Times on Pi4: real 170ms, user 34ms, sys 24ms
<syntaxhighlight lang "XPL0">func IsIdoneal(N); \Return 'true' if N is an Idoneal number
int N, A, B, C, AB, S, T;
[for A:= 1 to N do
for B:= A+1 to N do
[AB:= A*B;
S:= A+B;
if AB+S > N then B:= N
else for C:= B+1 to N do
[T:= AB + C*S;
if T = N then return false;
if T > N then C:= N;
];
];
return true;
];
 
int N, C;
[N:= 1; C:= 0;
Format(5, 0);
loop [if IsIdoneal(N) then
[RlOut(0, float(N));
C:= C+1;
if rem(C/13) = 0 then CrLf(0);
if C >= 65 then quit;
];
N:= N+1;
];
]</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 12 13 15
16 18 21 22 24 25 28 30 33 37 40 42 45
48 57 58 60 70 72 78 85 88 93 102 105 112
120 130 133 165 168 177 190 210 232 240 253 273 280
312 330 345 357 385 408 462 520 760 840 1320 1365 1848
</pre>
295

edits