Added algorithm to find gcd of two numbers

This commit is contained in:
2021-02-11 20:18:39 -05:00
parent 9d9ef62a6d
commit eb9f018d1f

View File

@@ -342,3 +342,14 @@ function isFound(ary, key)
end
return false;
end
function gcd(num1, num2)
while((num1 ~= 0) and (num2 ~= 0)) do
if(num1 > num2) then
num1 = num1 % num2;
else
num2 = num2 % num1;
end
end
return num1 | num2;
end