RafalSobala

zad 18

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