rajeevs1992

GCD-Euclid's Algorithm

Jul 17th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<process.h>
  3. void gcd(int,int);
  4.  
  5. void main()
  6. {
  7.     int a,b;
  8.     printf("\nEnter the nos ");
  9.     scanf("%d%d",&a,&b);
  10.     gcd(a,b);
  11. }
  12.  
  13. void gcd(int a,int b)
  14. {
  15.     if(a==0)
  16.     {
  17.         printf("\nGCD is %d",b);
  18.         exit(0);
  19.     }
  20.     a>=b?gcd(a%b,b):gcd(b%a,a);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment