2017-10-19 10:04:14 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
// Euclid's algorithm
|
2020-05-29 20:23:24 +00:00
|
|
|
int GCD(int x, int y)
|
|
|
|
{
|
2017-10-19 10:19:44 +02:00
|
|
|
if (y == 0)
|
2017-10-19 10:04:14 +02:00
|
|
|
return x;
|
2020-05-29 20:23:24 +00:00
|
|
|
return GCD(y, x % y);
|
2017-10-19 10:04:14 +02:00
|
|
|
}
|
|
|
|
|
2020-05-29 20:23:24 +00:00
|
|
|
int main()
|
|
|
|
{
|
2017-10-19 10:04:14 +02:00
|
|
|
int a, b;
|
|
|
|
printf("Input two numbers:\n");
|
|
|
|
scanf("%d %d", &a, &b);
|
|
|
|
printf("Greatest common divisor: %d\n", GCD(a, b));
|
|
|
|
}
|