RafalSobala

zad 17

Mar 31st, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a, b;
  6.  
  7. int NWD(int a, int b){
  8.  
  9.     while(a>0){
  10.         a=a%b;
  11.         b=b-a;
  12.     }
  13.  
  14.     return b;
  15. }
  16.  
  17.  
  18.  
  19. int main()
  20. {
  21.     cout << "podaj a, b:" << endl;
  22.     cin >> a >>b ;
  23.     cout << NWD(a,b) << endl;
  24.  
  25. }
Add Comment
Please, Sign In to add comment