Advertisement
aiNayan

7(v)

Dec 7th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. int gcd(int a, int b)
  3. {
  4. if (a == 0)
  5. return b;
  6. else if (b == 0)
  7. return a;
  8. else if (a == b)
  9. return a;
  10. if (a > b)
  11. return gcd(a - b, b);
  12. return gcd(a, b - a);
  13. }
  14. int main()
  15. {
  16. int a, b;
  17. printf("Enter the two number: ");
  18. scanf("%d%d", &a, &b);
  19. printf("GCD = %d ", gcd(a, b));
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement