Euclid's algorithm
Euclid's algorithm — efficient BC" title="Algorithm">Algorithm To Find 
Greatest Common Divisor  two 
Integers (or 
general measures  two 
Lines). The algorithm is named after 
Greek Math Euclid (3rd century B.C. ), who first described it in VII
  and X
 books «
Beginnings". It is one of the oldest numerical algorithms in use today.
Remember the math.
Greatest common divisor of two natural numbers (gcd) is the largest natural number by which they are divisible.
For example, the numbers 12 and 18 have common divisors: 2, 3, 6. The greatest common divisor is 6. This is written as: gcd(12, 18) = 6
In programming, there are several implementations of the Euclid algorithm. Here is a description of one of them in the form of a block diagram.

Try to implement this algorithm.