Advertisement
JakubBanachowski

Zad1.17

Mar 29th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int NWD (int a, int b)
  6. {
  7. if (a>b)
  8. {
  9. int c=a;
  10. a=b;
  11. b=a;
  12. }
  13. for (int i=a; i>0; i--)
  14. {
  15. if (a%i==0 && b%i==0)
  16. {
  17. return i;
  18. }
  19. }
  20. }
  21.  
  22. int main()
  23. {
  24. cout<<NWD(50,25)<<endl;
  25. cout<<NWD(1527,7252)<<endl;
  26. cout<<NWD(162,78)<<endl;
  27. cout<<NWD(124,908)<<endl;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement