RosettaCodeData/Task/Greatest-common-divisor/Lua/greatest-common-divisor-1.lua
2019-09-12 10:33:56 -07:00

15 lines
218 B
Lua

function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
function demo(a,b)
print("GCD of " .. a .. " and " .. b .. " is " .. gcd(a, b))
end
demo(100, 5)
demo(5, 100)
demo(7, 23)