Skip to content

Instantly share code, notes, and snippets.

@MihailJP
Created Jan 26, 2014
Embed
What would you like to do?
Implementation of Euclidian algorithm
function gcd(a, b)
local x = a; local y = b
repeat
if x > y then
x = math.fmod(x, y)
else
y = math.fmod(y, x)
end
until x == 0 or y == 0
return x + y
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment