Jump to content

Pythagorean quadruples: Difference between revisions

Version 2: cleanup the code; removed useless variable, moved variable declarations, added missing final end of line in output.
(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>importconst sequtilsN = 2_200
 
const N = 2_200
const N2 = N * N * 2
 
var r = newSeq[bool](N + 1)
var
a2, d, s1, s2 = 0
s = 3
r = newSeq[bool](N + 1)
ab = newSeq[bool](N2 + 1)
var ab = newSeq[bool](N2 + 1)
for a in 1..N:
let a2 = a * a
for b in a..N:
ab[a2 + b * b] = true
 
var s = 3
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>
<pre>
Same as Version 1.
</pre>
 
=={{header|Pascal}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.