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 <stdio.h>

int main(void)
{
    int a, b, r;
    int count = 1;
    
    while(scanf("%d %d", &a, &b) != EOF) {
        if(a == 0 && b == 0) {
            break;
        }
        
        while( (r = a % b) != 0 ) {
            
            a = b;
            b = r;
            count++;
            
        }
        printf( "%d %d\n", b, count );
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a,b;
	cin >> a >> b;
	if(a == 0 && b == 0) break;
	int ans = 1;
	if(a < b) swap(a,b);
	while(a % b != 0){
	    int temp = b;
	    b = a % b;
	    a = temp;
	    ans++;
	}
	cout << b << " " << ans << endl;
    }
    return 0;
}

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

int gcd( int x, int y, int* count )
{
	int t;
	*count = 0;
	if( x < y ){
		t = x;
		x = y;
		y = t;
	}
	while( 1 ){
		++*count;
		if( ( t = x % y ) == 0 ){
			break;
		}
		x = y;
		y = t;
	}
	return y;
}

int main()
{
	int x, y;
	while( cin >> x >> y  && ( x != 0 || y != 0 ) ){
		int count = 0;
		int g = gcd( x, y, &count );
		cout << g << " " << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;
int co;

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

int main(){
	while (cin >> a >> b&&a+b){
		co = 0;
		int ans = gcd(a, b);
		cout << ans << " " << co << endl;
	}
}

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

int GCD(int n, int m)
{
  cnt++;
  if (n == 0) return m;
  return GCD(m % n, n);
}

int main()
{
  int n, m;
  while (cin >> n >> m && n + m != 0){
    cnt = 0;
    if (n > m){
      int c = n;
      n = m;
      m = c;
    }
    cout << GCD(n, m) << " " << --cnt << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int gcd(int w,int m,int &cnt){
  return m==0?w:gcd(m,w%m,++cnt);
}

int solve(int *a){
  int cnt=0;
  cout << gcd(a[0],a[1],cnt)<<" " << cnt << endl;
}

main(){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    solve(a);
  }
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y;
  while(cin >> x >> y){
    int count=0, temp;
    if(x==0 && y==0) break;
    while(y!=0){
      x = x % y;
      temp = x;
      x = y;
      y = temp;
      count++;
    }
    cout << x  << ' ' << count << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
	while(1){
	int a,b,c;
	cin>>a>>b;
	if(a==0 && b==0){break;}

	int count=0;
	while(b!=0){
		a=a%b;
		swap(a,b);
		count++;

	}
	cout<<a<<" "<<count<<endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

int main() {
	for(int x, y; cin >> x >> y, x || y;) {
		if(x < y) swap(x, y);
		int cnt = 0;
		while(y != 0) {
			x = x % y;
			swap(x, y);
			cnt++;
		}
		cout << x << " " << cnt << endl;
	}
}

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)<<" "<<counter<<endl;
   }
   return 0;
}

C++: #include <iostream>

using namespace std;

int Euclid(int a, int b, int& step)
{
	if(b == 0)
	{
		return(a);
	}
	else
	{
		++step;
		return(Euclid(b, a % b, step));
	}
}

void solve()
{
	int a, b;
	while(cin >> a >> b, a || b)
	{
		if(a < b)
		{
			swap(a, b);
		}
		int step = 0;
		cout << Euclid(a, b, step);
		cout << " " << step << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

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

int main(){

  unsigned long long int a,b,c,r,count;

  while(cin >> a >> b, a, b){
    count = 0;

    while(b!=0){

      c = a/b;
      r = a%b;
      a = b;
      b = r;

      count++;

    }

    cout << a << ' ' << count << endl;

  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){

	int x, y;
	while(1){
		cin >> x >> y;
		int tmp = max(x, y);
		y = min(x, y);
		x = tmp;
		if(x == y && x == 0)break;
		int cnt = 1;
		while(1){
			int ab = x % y;
			if(ab == 0){
				cout << y << " " << cnt << endl;
				break;
			}
			x = y;
			y = ab;
			cnt++;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}