Idoneal numbers: Difference between revisions

Add CLU
m (Added the solution to the task in the Wolfram Language)
(Add CLU)
Line 210:
312 330 345 357 385 408 462 520 760 840 1320 1365 1848
Calculations took 28.5862 ms</pre>
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">idoneal = proc (n: int) returns (bool)
for a: int in int$from_to(1, n) do
for b: int in int$from_to(a+1, n) do
if (a*b + a + b > n) then exit b_high end
for c: int in int$from_to(b+1,n) do
sum: int := a*b + b*c + a*c
if sum=n then return(false) end
if sum>n then exit c_high end
end
except when c_high: end
end
except when b_high: end
end
return(true)
end idoneal
 
idoneals = iter (amt: int) yields (int)
n: int := 0
while amt > 0 do
n := n + 1
if idoneal(n) then
yield(n)
amt := amt-1
end
end
end idoneals
 
start_up = proc ()
po: stream := stream$primary_input()
col: int := 0
for i: int in idoneals(65) do
stream$putright(po, int$unparse(i), 5)
col := col + 1
if col = 13 then
stream$putl(po, "")
col := 0
end
end
end start_up</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>
 
=={{header|FreeBASIC}}==
2,114

edits