Special pythagorean triplet: Difference between revisions
m
→{{header|Ring}}: minor deletes, whitespace
(→{{header|Ring}}: various methods illustrated) |
m (→{{header|Ring}}: minor deletes, whitespace) |
||
Line 895:
# then scale to fit the actual perimeter
st = clock()
for m = 1 to 4
nd = md + 2 ns = ms + nd
Line 906:
et = clock() - st
a = n * m << 1 b = ns - ms c = ns + ms d = p / (((n * m) + ns) << 1)
? "a = " + a * d + " b = " + b * d + " c = " + c * d
? "Elapsed time = " + et / tf + " ms" + nl
? "alternate method:" # only uses addition / subtraction inside the
# makes a guess, then tweaks the guess until correct
st = clock()
Line 921:
end
et = clock() - st
? "a = " + a + " b = " + b + " c = " + (p - a - b)
? "Elapsed time = " + et / tf + " ms" + nl
Line 944:
even quicker method:
a = 200 b = 375 c = 425
Elapsed time = 0.18 ms
alternate method:
a = 200 b = 375 c = 425
Elapsed time = 0.44 ms
|