Greatest common divisor: Difference between revisions

Content added Content deleted
(→‎{{header|AutoHotkey}}: Changed non-recursive version (slightly faster))
Line 240: Line 240:
Return b=0 ? Abs(a) : Gcd(b,mod(a,b))
Return b=0 ? Abs(a) : Gcd(b,mod(a,b))
}</lang>
}</lang>
Significantly faster than the recursive version above:
Significantly faster than recursion:
<lang AutoHotkey>gcd(a, b) {
<lang AutoHotkey>GCD(a, b) {
while b
while b
t := b, b := Mod(a, b), a := t
b := Mod(a | 0x0, a := b)
return, a
return a
}</lang>
}</lang>