Special pythagorean triplet: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added a glyph to the last comment.)
Line 122: Line 122:
0.001073 seconds (20 allocations: 752 bytes)
0.001073 seconds (20 allocations: 752 bytes)
</pre>
</pre>

=={{header|Nim}}==
My solution from Project Euler:

<lang Nim>import strformat
from math import floor, sqrt

var
p, s, c : int
r: float

for i in countdown(499, 1):
s = 1000 - i
p = 1000 * (500 - i)
let delta = float(s * s - 4 * p)
r = sqrt(delta)
if floor(r) == r:
c = i
break

echo fmt"Product: {p * c}"
echo fmt"a: {(s - int(r)) div 2}"
echo fmt"b: {(s + int(r)) div 2}"
echo fmt"c: {c}"</lang>

{{out}}
<pre>Product: 31875000
a: 200
b: 375
c: 425</pre>


=={{header|PL/M}}==
=={{header|PL/M}}==