Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(buf[0])
		b, _ := strconv.Atoi(buf[1])
		if a == 0 && b == 0 {
			break
		}
		if a < b {
			a, b = b, a
		}
		cnt := 0
		for b != 0 {
			a = a%b
			a, b = b, a
			cnt++
		}
		fmt.Println(a, cnt)
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,num;
    while(cin>>x>>y,x&&y){
        for(int i=1;;i++){
            num=x%y;
            x=y;
            y=num;
            if(!num){
                cout<<x<<" "<<i<<endl;
                break;
            }
        }
    }
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
int ans;
void gcd(ll x,ll y){
	if(x<y) swap(x,y);
	if(y==0) return;
	ans++;
	gcd(y,x%y);
}


void mainmain(){
	ll x,y;
	while(cin>>x>>y,x){
		ans=0;
		gcd(x,y);
		cout<<__gcd(x,y)<<" "<<ans<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

int counter;

int gcd(int a, int b){
       if (b == 0) return a;
       else return gcd(b, a%b);
       counter++;
   }

int main(void){
   int a, b;
    while(cin>>a>>b){
    if(a < b){
           x = a;
           a = b;
           b = x;
       }
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int counter;
int gcd(int a, int b){  
    if (b == 0)
    return a;    
    counter++;      
    return gcd(b, a%b);  
}
int main(void){ 
    int a, b, x;    
    while(cin>>a>>b){      
        if(a < b){         
            x = a;         
            a = b;        
            b = x;       
            }     
            if(a == 0 && b == 0)
            return 0;       
            counter = 0;    
            cout<<gcd(a,b)<<" ";
            cout<<counter<<endl;   
            }    
            return 0;
    
}

C++: #include<iostream>
using namespace std;

int main(){
  while(1){
    long int a,b,dab,count=0;
    cin >> a >> b;
    if(a==0 && b == 0) break;
    if(a<b) swap(a,b);
    while(1){
      dab=a%b;
      a=b;
      b=dab;
      count++;
      if(dab==0) break;
    }
    cout << a << " " << count << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
   int gcd(int a, int b){
       if (b == 0) return a;
       else return gcd(b, a%b);
       counter++;
   }

int main(void){
   int a, b, counter;
    while(cin>>a>>b){
    if(a < b){
           x = a;
           a = b;
           b = x;
       }
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int N;
	int n[4] = {0};
	int L, S;
	int i;
	int x;
	int tmp;
	int k;
	int c;
	int h;
	
	c = 0;
	
	while (1){
		scanf("%d", &N);
		
		if (N == 0){
			break;
		}
		h = 0;
		while (1){
			if (N == 6174){
				break;
			}
			for (k = 0; k <= 3; k++){
				n[k] = N % 10;
				N /= 10;
			}
			if (n[0] == n[1] && n[1] == n[2] && n[2] == n[3]){
				h = 1;
				break;
			}
			for (i = 0; i <= 3; i++){
				for (x = 0; x <= 3; x++){
					if (n[i] > n[x]){
						tmp = n[x];
						n[x] = n[i];
						n[i] = tmp;
					}
				}
			}
			L = 0;
			for (k = 0; k <= 3; k++){
				L = L * 10 + n[k];
			}
		
				for (i = 0; i <= 3; i++){
				for (x = 0; x <= 3; x++){
					if (n[i] < n[x]){
						tmp = n[x];
						n[x] = n[i];
						n[i] = tmp;
					}
				}
			}
			S = 0;
			for (k = 0; k <= 3; k++){
				S = S * 10 + n[k];
			}
			N = L - S;
			c++;
			
		}
		if (h == 0){
			printf("%d\n", c);
			c = 0;
		}
		else {
			printf("NA\n");
		}
	}
	return (0);
}

C++: #include <iostream>

using namespace std;

int main(int argc, char** argv)
{
	int n, m;
	int x, y, d, c;

	while(cin >> n >> m, n || m)
	{
		if(n >= m)
		{
			x = n;
			y = m;
		}
		else
		{
			x = m;
			y = n;
		}

		c = 0;
		while(y != 0)
		{
			d = x % y;
			x = y;
			y = d;
			c++;
		}

		cout << x << " " << c << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<utility>
using namespace std;

int main(){
  int x,y,tmp;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    int cou = 0;
    while(y != 0){
      tmp = x % y;
      x = tmp;
      swap(x,y);
      cou++;
    }
    cout << x << " " << cou << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int cnt;

int gcd(int a,int b){ 
  if(a==0 || b==0) return 0;
  if(a<b) swap(a,b);
  while(b!=0) {
    a%=b;
    swap(a,b);
    cnt++;
  }
  return a;
}

int main() {
  int a,b;
  while(cin >> a >> b && (a!=0 || b!=0)) {
    cnt=0;
    int g=gcd(a,b);
    cout << g << " " << cnt << endl;
  }
  return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a!=0){
    int c=0;
    if(b==a){
     cout<<a<<" "<<1<<endl;
     goto at;
   }
   int x,y;
   if(a>b){
     x=a,y=b;
   }else{
     x=b,y=a;
   }
   while(y>0){
     x=x%y;
     int s=x;
     x=y;
     y=s;
     c++;
   }
   cout<<x<<" "<<c<<endl;
 at:;
 }
 return 0;   
}