mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
Merge pull request #82 from fsharpasharp/GCD
I have merged your code. Can you put in some comments.
This commit is contained in:
commit
af3648c678
15
misc/GCD.c
Normal file
15
misc/GCD.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#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));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user