Pythagorean triples: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
(Added Algol 68) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 383:
=={{header|ALGOL 68}}==
Uses a table of square roots so OK for perimeters up to 1000 (or possibly 10 000)
<syntaxhighlight lang="algol68">
BEGIN # find some Pythagorean triples ( a, b, c ) #
Line 1,397:
=={{header|Delphi}}==
See [[#Pascal|Pascal]].
=={{header|EasyLang}}==
{{trans|C}}
<syntaxhighlight>
global total prim maxperi .
proc newtri s0 s1 s2 . .
p = s0 + s1 + s2
if p <= maxperi
prim += 1
total += maxperi div p
newtri s0 - 2 * s1 + 2 * s2 2 * s0 - s1 + 2 * s2 2 * s0 - 2 * s1 + 3 * s2
newtri s0 + 2 * s1 + 2 * s2 2 * s0 + s1 + 2 * s2 2 * s0 + 2 * s1 + 3 * s2
newtri -s0 + 2 * s1 + 2 * s2 -2 * s0 + s1 + 2 * s2 -2 * s0 + 2 * s1 + 3 * s2
.
.
for maxperi in [ 100 10000000 ]
prim = 0
total = 0
newtri 3 4 5
print "Up to " & maxperi & ": " & total & " triples, " & prim & " primitives"
.
</syntaxhighlight>
=={{header|EDSAC order code}}==
Line 5,300 ⟶ 5,322:
{{trans|Go}}
Limited to a maximum perimeter of 10 billion in order to finish in a reasonable time.
<syntaxhighlight lang="
var total = 0
var prim = 0
|