Special pythagorean triplet: Difference between revisions
→{{header|Ring}}: illustrating straightforward method vs. faster method.
m (→{{header|REXX}}: updated output, added wording to the REXX section header.) |
(→{{header|Ring}}: illustrating straightforward method vs. faster method.) |
||
Line 821:
=={{header|Ring}}==
<lang ring>
▲see "working..." + nl
? "brute force method:"
time1 = clock()
for a = 1 to
c = 1000
if
?
ok
next▼
next
time2 = clock()
? "Elapsed time = " + (time2 - time1) / 1000 + " ms"
? "quick method:"
time1 = clock()
n = 1000
n2 = n >> 1
for a = 1 to n2
b = n * (n2 - a)
if b % (n - a) = 0 exit ok
b /= (n - a)
? "a = " + a + " b = " + b + " c = " + (n - a - b)
time2 = clock()
see "done..."
{{out}}
Quicker method is about 1000x faster.
<pre>working...
brute force method:
a = 200 b = 375 c = 425
Elapsed time = 927.21 ms
quick method:
a = 200 b = 375 c = 425
Elapsed time =
done...</pre>
=={{header|Wren}}==
|