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<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y)swap(x,y);
    rep(i,max(x,y)){
      x=x%y;
      swap(x,y);
      if(y==0)break;
    }
    cout<<x<<" "<<i+1<<endl;
  }
}

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

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	long long x,y;
	while(true){
	cin>>x>>y;
	if(x==0&&y==0)
		break;
	int i=1;
	while(true){
		x%=y;
		int tmp=x;
		x=y;
		y=tmp;
		if(y==0)
			break;
		i++;
	}
	cout<<x<<" "<<i<<endl;
	}
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	long long int x,y,temp,X,cnt;
	while(1){
		cnt=0;
		scanf("%lld %lld",&x,&y);
		if(x==0&&y==0)break;
		if(x<=y){
			temp=x;
			x=y;
			y=temp;
		}
		while(1){
			if(y==0)break;
			cnt++;
			X=x%y;
			x=y;
			y=X;
		}
		printf("%lld %lld\n",x,cnt);
	}
	return 0;
}

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

int main(){
    int cnt;
    int a,b;
    int x,y,q,r;
    while(1){
        cnt = 0;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        a = x;
        b = y;
        while(1){
            cnt++;
            q = x/y;
            r = x -q*y;
            if(r == 0) break;
            x = y;
            y = r;
        }
        cout << y << " " << cnt << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    while(cin >> a >> b, a){
        int cnt = 0;
        if(a < b) swap(a, b);
        while(b){
            cnt++;
            a %= b;
            swap(a, b);
        }
        cout << a << " " << cnt << "\n";
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
//ユークリッドの互除法を再帰で解くプログラム

int gcd(int a,int b,int count){
    if(b != 0){
        gcd(b,a%b,count+1);
    }else{
        cout << a << " " << count << endl;
    }
    return 0;
}

int main(){
    int a,b;
    while (cin >> a >> b) {
        if (a == 0 && b == 0){
            break;
        }else{
            gcd(max(a,b),min(a,b),0);
        }
    }
    return 0;
}

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

int main()
{
    int a, b;

    while( cin >> a >> b )
    {
        if( a == 0 && b == 0 )
            break;
        int c = 0;
        if( a < b )
        {
            int temp = a;
            a = b;
            b = temp;
        }
        while( b != 0 )
        {
            int temp = b;
            b = a % b;
            a = temp;
            c++;
        }
        cout << a << " " << c << 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 <stdio.h>
int main(){
  long x,y,a;
  int counter=0;

  while(1){
    scanf("%ld %ld0",&x,&y);
    if(x==0||y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%ld %d\n",y,counter);
    counter=0;
  }
  return 0;
}

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

int gcd(int x,int y,int& step){
	int n = 0;
	if( x < y ) swap( x , y );

	do{
		x = x % y;
		swap( x , y );
		n++;
	}while( y != 0 );
	step = n;
	return x;
}

int main(){
	int a,b,n;

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

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

typedef long long ll;

int ct=0;

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

int main(){
	int x,y;
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		if(x<=y){
			int tmp=x;
			x=y;
			y=tmp;
		}
		ct=0;
		int ans=gcd(x,y);
		cout<<ans<<" "<<ct<<endl;
	}
	return 0;
}

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

int euclid(int a, int b) {
	int cnt = 0;
	while (a == 0 || b == 0) {
		if (a >= b) { a = a%b; }
		else { b = b%a; }
		cnt++;
	}
	return cnt;
}

int main() {
	int x, y;
	while (true) {
		cin >> x >> y;
		if (x + y == 0) { break; }
		cout << __gcd(x, y) << ' ' << euclid(x, y) << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,temp;
	while(1){
		c=0;
		cin >> a >> b;
		if(a==b && a==0){
			break;
		}
		while(1){
			if(a<b){
				temp=a;
				a=b;
				b=temp;
			}
			a=a%b;
			c++;
			if(a==0){
				cout << b << ' ' << c << endl;
				break;
			}else{
				temp=a;
				a=b;
				b=temp;
			}
		}
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int c = 0;
long long int gcd(long long int l, long long int r) {

	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		c++;
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}

int main() {
	while (1) {
		int a, b; cin >> a >> b;
		if (!a)break;
		if (a > b)swap(a, b);
		c = 0;
		int agcd = gcd(a, b);
		cout << agcd << " " << c << endl;
	}
	return 0;
}

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

int mygcd ( int a, int b, int &S ) {

    if ( b == 0 ) {
        return ( a );
    }
    S++;

    return ( mygcd ( b, a % b, S ) );

}
int main()
{
    int A, B;
    int S = 0;

    while ( cin >> A >> B, A || B ) {

        int div = mygcd(A, B, S);

        cout << div << " " << S << endl;
    }

    return ( 0 );
}

C++: #include <stdio.h>
int ans;int gcd(int a, int b) {if (a<b) a+=b,b=a-b,a-=b;if (!b) return a;a%=b,ans++;return gcd(a,b);}
int main() {int a,b;while (scanf("%d %d",&a,&b)!=EOF && (a || b)) ans=0,a=gcd(a,b),printf("%d %d\n",a,ans);return 0;}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	long long a,b;
	while(cin>>a>>b&&a!=0&&b!=0){
		long long cnt=0;
		while(b!=0){
			a=a%b;
			swap(a,b);
			cnt++;
		}
		cout<<a<<" "<<cnt<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int x,y,temp,X,e,cnt;
	while(1){
		cnt=0;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		while(1){
			cnt++;
			X=x%y;
			x=y;
			y=X;
			if(y==0)break;
		}
		printf("%d %d\n",x,cnt);
	}
	return 0;
}