Pythagorean quadruples: Difference between revisions

Content added Content deleted
m (→‎version 2: changed BuildSumA2B2 For b := a to maxfacot => For b := 1 to a do speedup for bigger MaxFactor 4.2s -> 3,8s)
Line 1,000: Line 1,000:
Same as Version 1.
Same as Version 1.
</pre>
</pre>

=={{header|Lua}}==
{{trans|}}
<lang lua>-- initialize
local N = 2200
local ar = {}
for i=1,N do
ar[i] = false
end

-- process
for a=1,N do
for b=a,N do
if (a % 2 ~= 1) or (b % 2 ~= 1) then
local aabb = a * a + b * b
for c=b,N do
local aabbcc = aabb + c * c
local d = math.floor(math.sqrt(aabbcc))
if (aabbcc == d * d) and (d <= N) then
ar[d] = true
end
end
end
end
-- print('done with a='..a)
end

-- print
for i=1,N do
if not ar[i] then
io.write(i.." ")
end
end
print()</lang>
{{out}}
<pre>1 2 4 5 8 10 16 20 32 40 64 80 128 160 256 320 512 640 1024 1280 2048</pre>


=={{header|Modula-2}}==
=={{header|Modula-2}}==