Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. int gcd(int a, int b)
  2. {
  3.     if((a==0) || (b==0))
  4.         return 0; // to only check numbers if they are different from 0
  5.     else if((a < 0) || (b < 0))
  6.         return 0;
  7.  
  8.     do
  9.     {
  10.         while(a<b)
  11.             b - a;
  12.         while(b<a)
  13.             a - b;
  14.     }
  15.     while(a!=b);
  16.     return a;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement