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<cstdio>

using namespace std;

void change(int *, int *);

int main(void)
{
	int x, y;
	
	while(scanf("%d %d", &x, &y)){
		int count = 0;
		if(x < y)
			change(&x, &y);
		while(y){
			count++;
			x %= y;
			change(&x, &y);
		}
		cout << x << ' ' << count << endl;
	}
	return 0;
}

void change(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
	
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int x,y;

  while( cin >> x >> y , x || y ){

    int count = 0;
    while(y){
      if( x < y ) swap( x, y );
      int s = x % y;   
      x = y;
      y = s;
      count++;
    }
    cout << x << " " << count << endl;
  }
  return 0;
}

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 x,y;
void solve() {
  int step = 0;
  if (x < y) swap(x,y);
  while (y != 0) {
    x = x % y;
    swap(x,y);
    step++;
  }
  cout<<x<<" "<<step<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

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

int search(int n,int m,int &count){
  count++;
  if(n%m==0){return m;}
  else{return search(m,n%m,count);}
}




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

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

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

int main()
{
  int a, b;
  while(cin >> a >> b, a||b){
    int cnt = 0;

    while(b){
      a = a%b;
      swap(a, b);
      cnt++;
    }

    cout << a << " " << cnt << endl;

  }

  return 0;

}

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

int main(){
	int a,b;
	while(1){
	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++: 
// Greatest Common Divisor: Euclidean Algorithm
//  URL: http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0197&lang=jp

#include <cstdio>
#include <algorithm>

int main()
{
	int x, y;
	int steps;
	int gcd;

	while( 1 )
	{
		// ú»
		steps = 0;

		// lÌüÍ
		std::scanf( "%d%d", &x, &y );

		// üÍÌIíèÍ[2Â
		if( x == 0 && y == 0 ) break;

		// to do:
		//  [NbhÌÝ@ÅÅåöñðßé
		//  vZÉ©©Á½Xebvðßé

		// x >= y É·é: x < y ÈçüêÖ¦é
		if( x < y ) std::swap( x, y );

		// x / y Ì]èðxÉãü
		// lðüêÖ¦é
		// yª0ÉÈéÜÅ: yª0æèå«¯êÎ
		while( y > 0 )
		{
			x = x % y;
			std::swap( x, y );
			++steps;
		}

		// xÌlªÅåöñ
		gcd = x;

		// ÊðoÍ
		std::printf( "%d %d\n", gcd, steps );

	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int gcd( int x, int y, int &t)
{
	t = 0;
	int a = 0;

	if( x < y ) swap( x,y );

	while( y != 0 ){
		a = x % y; x = y; y = a;t++;
	}

	return x;
}

int main(int argc, char const* argv[])
{
	int x,y;

	while( cin >> x >> y && x != 0 )
	{
		int t;
		int a = gcd ( x, y ,t );

		cout << a << " " << t << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    int a,b,i,x=0,y=0,count={0};
    cin>>a>>b;
    if(a<=b){
        x=b;y=a;
    }else if(a>=b){
        x=a;y=b;
    }
    for(i=0;i<1000;i++){
        x=x%y;
        swap(x,y);
        count++;
        if(y==0){
            break;
        }
    }
    cout<<x<<" "<<count<<endl;
    return 0;
}

C++: #include <cstdio>
#include <algorithm>

int main()
{
	int x = 0, y = 0;
	int temp;
	int count;
	while (scanf("%d %d", &x, &y) != EOF) {
		if (x == 0 && y == 0) {
			break;
		}

		temp = 0;

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

		for (count = 0; y != 0; count++) {
			x = x % y;
			temp = x;
			x = y;
			y = temp;
		}

		printf("%d %d", x, count);

	}
	return 0;
}

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

int gcd(int x,int y){
	return y ? gcd(y,x%y)+1 : 0;
}
int main(){
	int x,y;
	while(cin >> x >> y && (x||y)){
		if( x < y ) swap(x,y);
		cout << __gcd(x,y) << " " << gcd(x,y) << endl;	
	}
}

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

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

int main() {
  for(long long a, b; cin >> a >> b, (a || b); ) {
    cnt = 0;
    long long g = gcd(a, b);
    cout << g << " " << cnt << endl;
  }
}

C++: #include <bits/stdc++.h>

using namespace std;;

int main(){
  long xbox[1000];
  long ybox[1000];
  int size=0;
  long xtemp,ytemp;
  long x,y,swap,mod;
  long step;
  
  while(true){
    scanf("%ld %ld", &xtemp,&ytemp);
    if(xtemp == 0 && ytemp == 0) break;
    xbox[size] = xtemp;
    ybox[size] = ytemp;
    //printf("%d %d\n", xbox[size],ybox[size]);
    size++;
    }
  //size=1;
  //xbox[0] = 1071;
  //ybox[0] = 1029;
  for(int i=0; i<size; i++){
    step = 0;
    x = xbox[i];
    y = ybox[i];
    while(y!=0){
      mod = x%y;
      //printf("mod %d\n",mod);
      x = mod;
      swap = x;
      x = y;
      y = swap;
      step++;
    }
    printf("%ld %ld\n", x,step);
  }
}