Write a program that asks the user for two numbers and thand displays their greatest commor divisor.
The greatest common divisor for two integers is the greatest positive integer by which both integers can be divided without leaving a rest. The greatest common divisor of the integers 8
and 12
is, for example, 4
, because:
8
are 1
, 2
, 4
, and 8
12
are 1
, 2
, 3
, 4
, 6
, and 12
1
, 2
, and 4
4
.
8
12
The greatest common divisor of 8 and 12 is 4.
6
12
The greatest common divisor of 6 and 12 is 6.
15
20
The greatest common divisor of 15 and 20 is 5.
24
84
The greatest common divisor of 24 and 84 is 12.