Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int nwd(int a, int b)
- {
- while(a != b)
- {
- if(a>b)
- {
- a-=b;
- }
- else
- {
- b-=a;
- }
- }
- return a;
- }
- int nww(int a, int b)
- {
- return (a * b)/nwd(a, b);
- }
- int main()
- {
- int a, b;
- cout << "Podaj A: ";
- cin >> a;
- cout << "Podaj B: ";
- cin >> b;
- int iNWD = nwd(a, b);
- cout << "Najwiekszy wspolny dzielnik to: " << iNWD << endl;
- int iNWW = nww(a, b);
- cout << "Najwiekszy wspolna wielokrotnosc to: " << iNWW;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement