Logo

Programming-Idioms

History of Idiom 74 > diff from v37 to v38

Edit summary for version 38 by Zo:
New Lua implementation by user [Zo]

Version 37

2019-11-15, 19:52:51

Version 38

2020-03-02, 14:59:26

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Code
function gcd(a, b)
	if (b ~= 0) then
		return a
	else 
		return gcd(y, x%y)
	end
end
Comments bubble
should look something like this based on euclide algorithm