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>
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;
}

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;
}