Problems
easyGreatest Common Divisor (GCD)
2 Koda Coins

Greatest Common Divisor (GCD)

easy2s limit💾 64 MB

Description

Find the Greatest Common Divisor (GCD) of two integers A and B.

The Euclidean algorithm is defined by the recurrence:

$\gcd(A, B) = \gcd(B, A \bmod B) \text{ for } B \neq 0

\gcd(A, 0) = A


Input Format

  • Two integers A and B.

  • Output Format

  • Print \gcd(A, B)$.