mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-28 08:13:08 +03:00
56b72da9fb
...algorithms to the `math` folder. Co-authored-by: David Leal <halfpacho@gmail.com>
18 lines
278 B
C
18 lines
278 B
C
#include <stdio.h>
|
|
|
|
// Euclid's algorithm
|
|
int GCD(int x, int y)
|
|
{
|
|
if (y == 0)
|
|
return x;
|
|
return GCD(y, x % y);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int a, b;
|
|
printf("Input two numbers:\n");
|
|
scanf("%d %d", &a, &b);
|
|
printf("Greatest common divisor: %d\n", GCD(a, b));
|
|
}
|