Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int gcd(int a, int b)
- {
- if (a == 0)
- return b;
- else if (b == 0)
- return a;
- else if (a == b)
- return a;
- if (a > b)
- return gcd(a - b, b);
- return gcd(a, b - a);
- }
- int main()
- {
- int a, b;
- printf("Enter the two number: ");
- scanf("%d%d", &a, &b);
- printf("GCD = %d ", gcd(a, b));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement