PiotrJurek

Zad18

Mar 29th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int NWW(int a, int b)
  6. {
  7. int c=a*b;
  8. while(a!=b)
  9. {
  10. if(a>b)
  11. {
  12. a=a-b;
  13. }
  14. else
  15. {
  16. b=b-a;
  17. }
  18. }
  19. return c/a;
  20. }
  21.  
  22. int main()
  23. {
  24. cout << NWW(54, 26) << endl;
  25. cout << NWW(97, 5) << endl;
  26. cout << NWW(512, 1024) << endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment