Greatest Common Denominator¶
🎯 Implement the Euclidean Algorithm to determine the greatest common denominator of two integers.
Pseudocode¶
you have two integer numbers a and b
copy the value of b
set b to the modulo of a and b
set a to the copy of b
if b is not zero, go back to step 2.
a is the greatest common denominator of a and b
Tests¶
Use the following code to test your function:
assert gcd(6, 3) == 3
assert gcd(12, 8) == 4
assert gcd(42, 12) == 6
Translated with www.DeepL.com