C Program to Find GCD of two Numbers Using Recursion
GCD of two integers is the largest integer that can exactly divide both numbers without remainder
- // C program to find gcd using recursion
-
- #include <stdio.h>
-
- int main()
- {
- int no1, no2;
- printf("Enter two positive integers: ");
- scanf("%d %d", &no1, &no2);
- printf("G.C.D of %d and %d is %d.", no2, no2, gcd(no1,no2));
- return 0;
- }
- int gcd(int no1, int no2)
- {
- if (no2 != 0)
- return gcd(no2, no1%no2);
- else
- return no1;
- }
Output
