Advertisement
ekzolot

Untitled

Dec 22nd, 2021
99
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. using namespace std;
  3. int gcd(int a, int b, int & s){
  4.     s++;
  5.     if (b==0){
  6.         return a;
  7.     }else{
  8.         return gcd(b, a%b, s);
  9.     }
  10. }
  11. int main(){
  12.     int a, b;
  13.     cin>>a>>b;
  14.     int s=0;
  15.     cout<<gcd (a, b, s)<<endl;
  16.     cout<<s<<endl;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement