Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int gcd(int a, int b)
- {
- if((a==0) || (b==0))
- return 0; // to only check numbers if they are different from 0
- else if((a < 0) || (b < 0))
- return 0;
- do
- {
- while(a<b)
- b - a;
- while(b<a)
- a - b;
- }
- while(a!=b);
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement