Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void gcd(int,int);
- void main()
- {
- int a,b;
- printf("\nEnter the nos ");
- scanf("%d%d",&a,&b);
- gcd(a,b);
- }
- void gcd(int large,int small)
- {
- int rem=0;
- if(large>small)
- rem=large%small;
- else if(small>large)
- rem=small%large;
- else
- rem=0;
- if (rem==0)
- {
- if(large>small)
- printf("\nGCD is %d",small);
- else if(small>large)
- printf("\nGCD is %d",large);
- else
- printf("\nGCD is %d",large);
- }
- else if (small>large)
- gcd(large,rem);
- else if(small<large)
- gcd(small,rem);
- }
Advertisement
Add Comment
Please, Sign In to add comment