Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int cmmdc(int a, int b)
- {
- while (b)
- {
- int r = a%b;
- a = b;
- b = r;
- }
- return a;
- }
- int main()
- {
- int n, m;
- cin >> n >> m;
- int div = cmmdc(n, m);
- if (div % 2 == 0)
- div /= 2;
- while (div % 2 == 0)
- {
- div--;
- while (n%div != 0 && m%div!=0)
- div -= 2;
- }
- cout << div;
- cout << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement