Vla_DOS

№495

Feb 20th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. unsigned int f(unsigned int n, unsigned int m)
  4. {
  5.     if (n == m)
  6.     {
  7.         return n;
  8.     }
  9.     if (n > m)
  10.     {
  11.         return f(n - m, m);
  12.     }
  13.     return f(n, m - n);
  14. }
  15. int main()
  16. {
  17.     setlocale(LC_ALL, "rus");
  18.     unsigned int n, m;
  19.     cout << "Введите первое положительное целое число: ";
  20.     cin >> n;
  21.     cout << "Введите второе положительное целое число: ";
  22.     cin >> m;
  23.     cout << "Наибольший общий делитель: " << f(n, m) << endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment