Advertisement
Lukasz_Miskiewicz

Zadanie 17

Mar 31st, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int a,b,c;
  4.  
  5. int nwd(int a, int b)
  6. {
  7. int c=a+b;
  8. while(a%c!=0 || b%c!=0)
  9. {c=c-1;}
  10. return c;
  11. }
  12.  
  13. int main()
  14. {
  15. cout<<"podaj dwie liczby naturalne"<<endl;
  16. cin>>a;
  17. cin>>b;
  18. cout<<"najwiekszy wspolny dzielnik to "<< nwd(a,b);
  19.  
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement