Anonymous user
Pythagorean quadruples: Difference between revisions
Version 2: cleanup the code; removed useless variable, moved variable declarations, added missing final end of line in output.
m (→Version 1) |
(Version 2: cleanup the code; removed useless variable, moved variable declarations, added missing final end of line in output.) |
||
Line 1,248:
===Version 2===
<lang>
const N2 = N * N * 2
s = 3▼
▲ r = newSeq[bool](N + 1)
ab = newSeq[bool](N2 + 1)▼
for a in 1..N:
let a2 = a * a
for b in a..N:
ab[a2 + b * b] = true
for c in 1..N:
var s1 = s
s += 2
var s2 = s
for d in (c+1)..N:
if ab[s1]: r[d] = true
s1 += s2
Line 1,277 ⟶ 1,273:
{{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|Pascal}}==
|