Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int gcd;
- void GCD(int,int);
- int main()
- {
- int n1,n2,gcd;
- printf("Enter the two numbers :\n");
- scanf("%d%d",&n1,&n2);
- GCD(n1,n2);
- }
- void GCD(int x,int y)
- {
- int c;
- if(x==0 )
- {
- gcd=y;
- printf("GCD=%d\n",gcd);
- }
- else if(y==0)
- {
- gcd=x;
- printf("GCD=%d\n",gcd);
- }
- else if(x>y)
- {
- x=x-y;
- GCD(x,y);
- }
- else
- {
- y=y-x;
- GCD(x,y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement