Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- unsigned int f(unsigned int n, unsigned int m)
- {
- if (n == m)
- {
- return n;
- }
- if (n > m)
- {
- return f(n - m, m);
- }
- return f(n, m - n);
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- unsigned int n, m;
- cout << "Введите первое положительное целое число: ";
- cin >> n;
- cout << "Введите второе положительное целое число: ";
- cin >> m;
- cout << "Наибольший общий делитель: " << f(n, m) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment