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<stdio.h>
int main(void)
{
    int x,y,w,c,i;
	scanf("%d %d",&x,&y);
	while(x!=0&&y!=0){
	    c=0;
		if(x<y){
            w=x;
            x=y;
            y=w;
        }
	    while(y!=0){
			    x=x%y;
				w=x;
				x=y;
				y=w;
				c++;
		}
	printf("%d %d\n",x,c);
	scanf("%d %d",&x,&y);
	}
	return 0;
}

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

using namespace std;

int main()
{
	while(true)
	{
		int x = 0, y = 0, count = 0;;

		cin >> x >> y;

		if(x == 0 && y == 0)
		{
			return false;
		}

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

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

			swap(x, y);
		}

		cout << x << ' ' << count << endl;
	}
}

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

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

using namespace std;

typedef long long ll;

int ct=0;

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

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

C++: #include <cstdio>

using namespace std;

int t, r;

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

int main()
{
    while( 1 )
    {
        int num1 = 0, num2 = 0;
        scanf( "%d %d\n", &num1, &num2 );
        if( num1 == 0 && num2 == 0 )break;
        t = 0;
        r = gcd( num1, num2 );
        printf( "%d %d\n", r, t );
    }
    return 0;
}

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

#define FOR(i, x, y) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  long long int x, y;
  while (cin >> x >> y, x + y){
    int cnt = 0;
    while (y != 0){
      long long int tmp = y;
      y = x % y;
      x = tmp;
      cnt++;
    }
    cout << x << " " << cnt << endl;
  }
}

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


int main() {
  int a, b;
  while (1) {
    cin >> a >> b;
    if (!a && !b) {
      break;
    }
    int d = 0;
    if (a < b) {
      int c = a;
      a = b;
      b = c;
    }
    while (b) {
      int c = a % b;
      a = b;
      b = c;
      ++d;
    }
    cout << a << " " << d << 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};
    for(i=0;i<1000;i++){
    cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
    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;
        count=0;
    }
    return 0;
}

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 x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y)swap(x,y);
    int i=0;
    while(y){
      x=x%y;
      swap(x,y);
      i++;
    }
    cout<<x<<" "<<i<<endl;
  }
}

C++: (){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    if ( a[0]<a[1])swap(a[0],a[1]);
    solve(a);
  }
}

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

int main(){

  int x,y,x1,y1;
  int cnt=0;

  while(1)
    {
      cin >> x >> y;

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

      /* x = max(x,y);
	 y = min(x,y);*/

      while(1)
	{
	  if(x!=y)
	    {
	      y1 = x%y;
	      x1 = y;
	      cnt++;
	      x = x1;
	      y = y1;
	      if(y == 0)break;
	    }
	  else
	    {
	      cnt = 1;
	      break;
	    } 
	}
      cout << x << " " << cnt << endl;
    }

C++: #include<iostream>

int c;

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

int main(){
	int x, y;
	while(true){
		c = 0;
		std:: cin >> x >> y;
		if(x == 0 && y==0)
			return 0;
		std:: cout << gcd(x, y) << ' ' << c << std::endl;
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n,a,s,i,d,c,j,x,g;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		if(a<s){
			n=a;
			a=s;
			s=n;
		}
		c=0;
		while(s!=0){
			a=a%s;
			g=a;
			a=s;
			s=g;
			c++;
		}	
		printf("%d %d\n",a,c);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b,r, kouyaku[1111], kazu[1111],kaisuu,s;
	kaisuu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0&&b == 0) {
			goto a;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b != 0) {
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
	a:;
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i]<<" " << kazu[i] << endl;
	}
}

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

int ans;
int gcd(int a, int b) {
	ans++;
	return a % b == 0 ? b : gcd(b, a % b);
}

int main() {
	int a, b;
	while(cin >> a >> b, a || b) {
		ans = 0;
		if(a < b)
			swap(a, b);
		int c;
		c = gcd(a,b);
		cout << c << " " << ans << endl;
	}
}

C++: // 2011/01/15 Tazoe

#include <iostream>
using namespace std;

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

		if(X<Y){
			int tmp = X;
			X = Y;
			Y = tmp;
		}

		int cnt = 0;
		do{
			X = X%Y;

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

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

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

	return 0;
}