Write a program that asks the user to enter two positive integers and then calculates their greatest common divisor (GCD).

Examples

If you enter the numbers 4 and 2, their greatest common divisor is 2. If you enter the numbers 16 and 24, their greatest common divisor is 8.

How to Find the Greatest Common Divisor

You know that the number 1 is always a common divisor, but it may not be the greatest. Therefore, you can check whether a number k (for k = 2, 3, 4, …) is a common divisor of both numbers until k becomes greater than one of the numbers.

Example Run

The text in red represents user input and is not printed by your program.

Enter number 1?
69
Enter number 2:
36
Greatest Common Divisor is 3