- b가 0이면, a가 GCD
- 아니면, a를 b로 나눈 나머지를 구함
- a에 b를 대입하고, b에 나머지를 대입
- 1번으로 돌아가 반복
Euclidean algorithm
In mathematics, the Euclidean algorithm, or Euclid's algorithm, is an efficient method for computing the greatest common divisor (GCD) of two integers (numbers), the largest number that divides them both without a remainder. It is named after the ancient Greek mathematician Euclid, who first described it in his Elements .
It is an example of an algorithm, a step-by-step procedure for performing a calculation according to well-defined rules,
and is one of the oldest algorithms in common use. It can be used to reduce fractions to their simplest form, and is a part of many other number-theoretic and cryptographic calculations.
https://en.wikipedia.org/wiki/Euclidean_algorithm

Seonglae Cho