Write a C program to find common divisors between two numbers in a given pair.
int GCDVal(int u, int v)
{
  while (u != v)
  {
    if (u > v) return GCDVal(u - v, v);
    else    return GCDVal(u, v - u);
  }
  return u;
}
main(void)
{
  int n1, n2, i, gcd;
  printf("Enter First Integer: "); scanf("%d",&n1);
  printf("Enter Second Integer: "); scanf("%d",&n2);
  gcd = GCDVal(n1,n2);
printf("G.C.D of %d and %d is %d", n1, n2, gcd);
  return 0;
}
Comments
Leave a comment