Pythagorean triples: Difference between revisions

Added Arturo implementation
m (Added Delphi reference to Pascal code)
(Added Arturo implementation)
Line 307:
510 LET SUM = temp
520 END FUNCTION</lang>
 
=={{header|Arturo}}==
 
<lang rebol>triples: new []
loop 1..50 'x [
loop 1..50 'y [
loop (max @[x y])..100 'z [
if 100 > sum @[x y z] [
if (z^2) = add x^2 y^2 ->
'triples ++ @[sort @[x y z]]
]
]
]
]
unique 'triples
 
print ["Found" size triples "pythagorean triples with a perimeter no larger than 100:"]
print triples
 
primitive: select triples => [1 = gcd]
 
print ""
print [size primitive "of them are primitive:"]
print primitive</lang>
 
{{out}}
 
<pre>Found 17 pythagorean triples with a perimeter no larger than 100:
[3 4 5] [5 12 13] [6 8 10] [7 24 25] [8 15 17] [9 12 15] [9 40 41] [10 24 26] [12 16 20] [12 35 37] [15 20 25] [15 36 39] [16 30 34] [18 24 30] [20 21 29] [21 28 35] [24 32 40]
 
7 of them are primitive:
[3 4 5] [5 12 13] [7 24 25] [8 15 17] [9 40 41] [12 35 37] [20 21 29]</pre>
 
=={{header|AutoHotkey}}==
1,532

edits