Advertisement
pasholnahuy

recurse algorythm evklida

May 4th, 2019
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int alg(int a,int  b){
  7.     if (a == 0 || b == 0){
  8.         return a + b;
  9.     }
  10.     return alg(b, a%b);
  11. }
  12.  
  13. int main()
  14. {
  15.     int a, b;
  16.     cin >>  a >> b;
  17.  
  18.     cout  <<  alg(a, b) <<  endl;
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement