17,105
edits
Falterfire (talk | contribs) (first attempt at p.tablesEqual) |
(Replace GCD function with an implementation of the Euclidean algorithm, so that fewer iterations occur when numbers differ greatly in magnitude) |
||
Line 270: | Line 270: | ||
end | end | ||
-- | -- Euclidean Greatest Common Divisor algorithm | ||
function p.gcd(a, b) | function p.gcd(a, b) | ||
if | if b ~= 0 then | ||
return a | return p.gcd(b, a % b) | ||
else | else | ||
return math.abs(a) | |||
end | end | ||
end | end |