Greatest common divisor P67723


Statement
 

pdf   zip

Write a program that computes the greatest common divisor of two numbers.

Input

Input consists of two strictly positive natural numbers aa and bb.

Output

Print the greatest common divisor of aa and bb.

Observation

Although the solution to this exercise does not need to be very efficient, it should not be too slow.

Public test cases
  • Input

    16104 3216
    
    

    Output

    The gcd of 16104 and 3216 is 24.
    
  • Input

    1107 15129
    

    Output

    The gcd of 1107 and 15129 is 369.
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python Rust