Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func gcd(x, y int) (int, int) {
	nSteps := 0
	for {
		if x < y {
			tmp := x
			x = y
			y = tmp
		}
		nSteps++
		if x%y == 0 {
			return nSteps, y
		}
		x = x % y
	}
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		a, _ := nextInt()
		b, _ := nextInt()

		if a == 0 && b == 0 {
			break
		}

		nSteps, p := gcd(a, b)
		fmt.Println(p, nSteps)
	}
}

C++: #include <iostream>
#include <cstdio>
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 counter;
   int a, b;
    while(cin>>a>>b){
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    return 0;
}

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

int count;

int gcd(int m,int n)
{
	if(n == 0)
		return m;
	count++;
	int tmp = m%n;
	return gcd(n,tmp);
}

int main()
{
	int m,n;
	while(cin >> m >> n){
		count = 0;
		if(m==0 && n==0)
			break;
		cout << gcd(m,n);
		cout << " " << count << endl;
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int a,b,c=0;
  while(cin>>a>>b,a!=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;   
}

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;
    while(cin>>a>>b){
        if(a == 0 && b == 0)
        return 0;
        counter = 0;
        cout<<gcd(a,b)<<" "<<counter<<endl;
        }
        return 0;}

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

void greatestCommonDivisor(int x, int y);

int main(){
	int a, b;
	while(scanf("%d %d", &a, &b)){
		if(a == 0 and b == 0) break;
		greatestCommonDivisor(a, b);
	}
	return 0;
}

void greatestCommonDivisor(int x, int y){
	int temp, count = 0;
	while(true){
		x %= y;
		temp = x;
		x = y;
		y = temp;
		if(y == 0) break;
		count++;
	}
	printf("%d %d\n", x, count + 1);
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

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

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef long double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}
bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

pair<int,int>gcd(int a,int b,int i=0){
  if(a>b)return gcd(b,a,i);
  if(a==0)return cons(b,i);
  return gcd(b%a,a,i+1);
}

int main() {

  loop {
    int a, b; cin >> a >> b;
    if (!a &&!b) break;
    auto p=gcd(a,b,0);
    cout<<car(p)<<' '<<cdr(p)<<endl;}

  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,x,y) for(int i=(x);i<(y);i++)
#define rrep(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	for (int x, y; cin >> x >> y&&x;) {
		int cnt = 0;
		while (y) {
			cnt++;
			int xx = x;
			x = y;
			y = xx%y;
		}
		cout << x << " " << cnt << endl;		
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int s,a,b;
int gcd(int x,int y){
	s++;
	return y?gcd(y,x%y):x;
}
int main(){
	while(cin>>a>>b,a)s=-1,cout<<gcd(a,b)<<" "<<s<<endl;
	return 0;
}

C++: // 2012/07/16 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int x, y;
		cin >> x >> y;

		if(x==0&&y==0)
			break;

		int X, Y;
		if(x>=y){
			X = x;
			Y = y;
		}
		else{
			X = y;
			Y = x;
		}

		int cnt = 0;

		do{
			X = X%Y;

			int tmp = X;
			X = Y;
			Y = tmp;

			cnt++;
		}while(Y!=0);

		cout << X << ' ' << cnt << endl;
	}

	return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
    while( 1 )
    {
        int num1 = 0, num2 = 0;
        scanf( "%d %d\n", &num1, &num2 );
        if( num1 == 0 && num2 == 0 )break;
        int cnt = 0;
        while( num2 != 0 )
        {
            int index = num2;
            num2 = num1 % num2;
            num1 = index;
            cnt++;
        }
        printf( "%d %d\n", num1, cnt );
    }
    return 0;
}

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x,y,s;
	while(cin>>x>>y,x){
		if(y>x)swap(x,y);
		for(s=0;y;)s++,x%=y,swap(x,y);
		cout<<x<<" "<<s<<endl;
	}
	return 0;
}