ENGIN 77 - Module 5 - while loop example 3

Опубликовано: 06 Май 2026
на канале: Mallory
25
0

Write a function with the header GCD = Euclid(A,B) that uses the Euclidean algorithm to find the greatest common denominator of A and B
The Euclidean Algorithm for finding the greatest common denominator of A and B is as follows:
if A is less than B, exchange A and B
divide A by B and get the remainder, R
If R=0, B is the greatest common denominator of A and B and we can stop the loop and report B as the GCD
If R is not equal to 0, replace A by B and replace B by R and repeat steps 2 and 3