MeehoweCK

Untitled

Dec 21st, 2020
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.18 KB | None | 0 0
  1. int nwd(int a, int b)
  2. {
  3.     if(a * b == 0)
  4.         return 1;
  5.     if(a < 0)
  6.         a = -a;
  7.     if(b < 0)
  8.         b = -b;
  9.     while(a != b)
  10.     {
  11.         if(a > b)
  12.             a -= b;
  13.         if(b > a)
  14.             b -= a;
  15.     }
  16.     return a;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment