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>
using namespace std;

int gcd(int a, int b, int step);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		gcd(a, b, 0);
	}

	return (0);
}

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

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

int res;

int gcd(int x, int y) {
  if(y == 0) return x;
  res++;
  return gcd(y,x%y);
}

int main() {
  int x,y;
  while(cin >> x >> y) {
    if(x==0 && y==0 || y==0) break;
    if(x < y) {
      swap(x,y);
    }
    res = 0;
    cout << gcd(x,y) << " " << res << endl;
  }
  return 0;
}

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

struct result{
  int step;
  int gcd;
};

void gcd(int a, int b, result* r);

int main(void){
  int a,b;
  result r;
  while(1){
    cin>>a>>b;
    if(a==0 and b==0)break;
    gcd(a,b,&r);
    cout<<r.gcd<<" "<<r.step<<endl;
  }
  return 0;
}

void gcd(int _a, int _b, result* r){
  int step=0;
  int a=min(_a,_b);
  int b=max(_a,_b);
  while(a!=0){
    int tmp=b%a;
    b=a;
    a=tmp;
    step+=1;
  }
  r->step=step;
  r->gcd=b;
}

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

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 

int main(void){  
  int a,b,m,n;
  while(cin>>a>>b,a||b){
    m = max(a,b);
    n = min(a,b);
    int count = 0;
    while(n!=0){
      int tmp = n;
      n = m%n;
      m = tmp;
      count++;
    }
    cout << m << " " << count << endl;
  }
  return 0;
}

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

C++: #include <iostream>

using namespace std;

int main() {
	long long int x, y;
	long long int kari;
	while (cin >> x >> y) {
		if (x == 0 && y == 0) {
			break;
		}
		if (x < y) {
			kari = x;
			x = y; 
			y = kari;
		}
		int counter = 0;
		while (y != 0) {
			counter++;
			x = x % y;
			kari = y;
			y = x;
			x = kari;
		}
		cout << x << " " << 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;    
        while(cin>>a>>b){  
            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(){
    long int cnt;
    long long a,b;
    long long x,y,q,r;
    while(1){
        cnt = 0;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        a = x;
        b = y;
        while(1){
            q = x/y;
            r = x -q*y;
            cnt++;
            if(r == 0) break;
            x = y;
            y = r;
        }
        cout << y << " " << cnt << endl;
    }
}

C++: #include <iostream>

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 <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int cnt;
int main(){
	int a,b;
	cnt=0;
	while(1){
		cin>>a>>b;
		if(a<b)swap(a,b);
		while(1){
			a%=b;
			swap(a,b);
			cnt++;
			if(b==0)break;
		}
		cout<<a<<" "<<cnt<<endl;
	}
}

C++: #include <stdio.h>
int T;
int gcd(int x, int y) {
	if(x == 0) return y;
	if(y == 0) return x; T++;
	if(x > y) return gcd(y, x % y);
	return gcd(x, y % x);
}
int main() {
    int a,b;
	while(true) {
		scanf("%d%d",&a,&b); T = 0;
		if(a==0&&b==0) return 0;
		printf("%d %d\n",gcd(a,b), T);
	}
}

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





int main(){
  long  x, y, s, t, u ,z;

  while(1){
    s = 0;
    cin>>x>>y;
    if(x == 0 && y == 0) break;

    if(x <= y) swap(x, y);
    
    while(y != 0){
      x = x%y;
      t =max(x, y);
      u =min(x, y);
      x = t; y =u;
      s++;
    }

    cout<<x<<" "<<s<<endl;
    
  }

  
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int X, Y;

pair<int, int> gcd_count(int X, int Y)
{
	int count = 0;

	do
	{
		X = X % Y;
		swap(X, Y);
		count++;
	} while (Y != 0);

	return make_pair(X, count);
}

signed main()
{
	while (true)
	{
		cin >> X >> Y;
		if (X == 0 && Y == 0) break;

		if (X < Y) swap(X, Y);
		pair<int, int> ans = gcd_count(X, Y);
		
		cout << ans.first << " " << ans.second << endl;
	}
}

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

int main() {
	int a, b, r;
	while(1){
		int count=1;
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		if(a<b){
			int tmp = a;
			a = b;
			b = tmp;
		}
		r = a%b;
		while(r != 0){
			a = b;
			b = r;
			r = a%b;
			count++;
		}
		cout << b << ' ' << count << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>

using namespace std;


int yuku(int x,int y){
	int t=x%y;
	x=y;
	y=t;
	if(y==0)return x;
	else yuku(x,y);


};
int yu(int x,int y,int sum){
	int t=x%y;
	x=y;
	y=t;
	sum++;
	if(y==0)return sum;
	else yu(x,y,sum);


};
 
int main(){

int x,y;
while(1){
cin>>x>>y;if(x==y&&x==0)break;
int R=yuku(x,y);
int sum=0;
sum=yu(x,y,sum);

cout<<R<<" "<<sum<<endl;
}
return 0;
}

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

int count;

int gcd(int m,int n)
{
	if(m < n){
		int t = m;
		m = n;
		n = t;
	}
	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++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int result[10000], step[10000];
	int suffix = 0;

	while (1) {
		long long x, y;

		scanf("%lld", &x);
		scanf("%lld", &y);

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

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}


		long long value = 1;
		int count = 0;

		while (1) {
			count++;
			value = x % y;

			if (value == 0) {
				result[suffix] = y;
				step[suffix] = count;
				suffix++;
				break;
			}

			x = y;
			y = value;
		}
	}

	for (int i = 0; i < suffix - 1; i++) {
		printf("%d %d\n", result[i], step[i]);
	}

	printf("%d %d", result[suffix - 1], step[suffix - 1]);

	return 0;
}