Showing posts with label calculate HCF using recursion in c. Show all posts
Showing posts with label calculate HCF using recursion in c. Show all posts

Monday, September 12, 2011

calculate HCF using recursion, Highest common factor

main()
{
    int a,b;
    clrscr();
    printf("\n Enter any two nos.:");
    scanf("%d %d",&a,&b);
    printf("\n HCF of the two nos.:%d",gcd(a,b));
    getch();
}

    gcd(int p,int q)
    {
      int r;
      r=p%q;
      if(r==0)
          return(q);
      else
          gcd(q,r);
      }

Popular 5 Posts Last 7 days