Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int nwd(int a, int b) // funkcja pobiera dwie liczby całkowite i zwraca ich największy wspólny dzielnik (lub 0)
- {
- if(a * b == 0)
- return 0;
- if(a < 0) a = -a;
- if(b < 0) b = -b;
- while(a != b)
- {
- if(a > b)
- a -= b;
- if(b > a)
- b -= a;
- }
- return a;
- }
- int main()
- {
- cout << nwd(12, 18) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement