Skip to content

Instantly share code, notes, and snippets.

@MihailJP
Created January 26, 2014 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MihailJP/8631332 to your computer and use it in GitHub Desktop.
Save MihailJP/8631332 to your computer and use it in GitHub Desktop.
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