Jump to content

Special pythagorean triplet: Difference between revisions

m (→‎{{header|REXX}}: added a glyph to the last comment.)
Line 122:
0.001073 seconds (20 allocations: 752 bytes)
</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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.