Advertisement
35657

Untitled

Apr 11th, 2024
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int g_c_d(int a, int b) {
  7.     if (a == b) {
  8.         return a;
  9.     }
  10.     return a > b ? g_c_d(a - b, b) : g_c_d(a, b - a);
  11. }
  12.  
  13.  
  14. int main() {
  15.     setlocale(LC_ALL, "ru");
  16.  
  17.     cout << g_c_d(3, 8) << endl;
  18.     cout << g_c_d(25, 125) << endl;
  19.     cout << g_c_d(6, 9) << endl;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement