Idoneal numbers: Difference between revisions

→‎{{header|PARI/GP}}: append Free Pascal Version
(Added C# version, translated from python version, Added Pari/GP version from OEIS source)
(→‎{{header|PARI/GP}}: append Free Pascal Version)
Line 68:
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|Pascal}}==
==={{header|Free Pascal}}===
copy of Raku/Python etc only reducing multiplies in sum.
<syntaxhighlight lang="pascal">
program idoneals;
{$IFDEF FPC} {$MODE DELPHI}{$OPTIMIZATION ON,ALL}{$ENDIF}
{$IFDEF WINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
function isIdoneal(n: Uint32):Boolean;
var
a,b,c,sum : Uint32;
begin
For a := 1 to n do
For b := a+1 to n do
Begin
if (a*b + a + b > n) then
BREAK;
sum := a*b + b*b + a*b;
For c := b+1 to n do
begin
{sum3 = a * b + b * c + a * c}
sum += a+b;
if (sum = n) then
EXIT(false);
if (sum > n) then
BREAK;
end;
end;
exit(true);
end;
 
var
n ,l: Uint32;
// idoneals : array of Uint32;
 
begin
l := 0;
For n := 1 to 1850 do
if isIdoneal(n) then
Begin
inc(l);
// setlength(idoneals,l); idoneals[l-1] := n;
write(n:5);
if l mod 13 = 0 then
Writeln;
end;
end.</syntaxhighlight>
{{out|@TIO.RUN}}
<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
 
Real time: 0.102 s User time: 0.081 s Sys. time: 0.020 s</pre>
 
=={{header|Python}}==
4

edits