Pythagorean quadruples: Difference between revisions

Content added Content deleted
(Undo revision 254643 by Paddy3118 (talk) time is w.r.t. second example.)
Line 493:
{{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|Python}}==
{{trans|Julia}}
<lang Python>def quad(top=2200):
r = [False] * top
ab = [False] * (top * 2)**2
for a in range(1, top):
for b in range(a, top):
ab[a * a + b * b] = True
s = 3
for c in range(1, top):
s1, s, s2 = s, s + 2, s + 2
for d in range(c + 1, top):
if ab[s1]:
r[d] = True
s1 += s2
s2 += 2
return [i for i, val in enumerate(r) if not val and i]
if __name__ == '__main__':
n = 2200
print(f"Those values of d in 1..{n} that can't be represented: {quad(n)}")</lang>
 
{{out}}
<pre>Those values of d in 1..2200 that can't be represented: [1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 128, 160, 256, 320, 512, 640, 1024, 1280, 2048]</pre>
 
=={{header|REXX}}==