Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a , b;
- void NWD()
- {
- for(int i=a; i>=1; i--)
- {
- if(a%i==0 && b%i==0)
- {
- cout<<i<<endl;
- break;
- }
- }
- }
- int main()
- {
- cout << "Podaj 2 liczby naturalne" << endl;
- cin >> a >> b;
- if(a<0 || b<0)
- {
- cout<<"To nie jest liczba naturalna"<<endl;
- }
- cout<<"Najwiekszy wspolny dzielnik to: ";
- NWD();
- return 0;
- }
Add Comment
Please, Sign In to add comment