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;


int main(void)
{
  int a, b, x, y, z, i=0;

  scanf("%d %d", &a, &b);

  if(a != 0 && b != 0)
  {
    if(a >= b)
    {
      x = a;
      y = b;
    }

    else
    {
      x = b;
      y = a;
    }

  do{
      x = x%y;
      z = x;
      x = y;
      y = z;
      i++;
     }while(y!=0);

  printf("%d %d\n", x, i);
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int m,n,o,cnt;
int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    if(n<m){
      o=n;
      n=m;
      m=o;
    }
    cnt=0;
    while(m!=0){
      cnt++;
      o=n%m;
      n=m;
      m=o;
    }
    cout<<n<<' '<<cnt<<endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	ll a,b;
	while(true){
		cin >> a >> b;
		if(a == 0 && b == 0)break;
		ll x = max(a,b);
		ll y = min(a,b);
		int count = 0;
		while(y != 0){
			x = x % y;
			ll t = x;
			x = y;
			y = t;
			count++;
		}
		cout << x << " " << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){

	int x, y;
	while(1){
		cin >> x >> y;
		if(x == y && x == 0)break;
		int cnt = 1;
		while(1){
			int ab = x % y;
			if(ab == 0){
				cout << y << " " << cnt << endl;
				break;
			}
			x = y;
			y = ab;
			cnt++;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    int a,b,i,j,x=0,y,count={0},memo;
    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 <iostream>
using namespace std;

int res=0;

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

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

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

int search(int n,int m,int &count){
  if(n%m==0){return m;}
  else{count++; 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+1<<endl;
  }
  
  return 0;
}

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

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        int count = 1;
        while (N % M) {
            int tmp = N % M;
            N = M;
            M = tmp;
            count++;
        }

        cout << M << " " << count << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int take;

int gcd(int n, int m)
{
    take++;
    if (m == 0)
        return n;
    return gcd(m, n % m);
}

int main()
{
    int n, m;

    while (cin >> n >> m, n || m) {
        take = 0;
        int ans = gcd(n, m);
        cout << ans << " " << take - 1 << endl;
    }

    return 0;
}

C++: /* 
 * File:   main.cpp
 * Author: freebsd
 *
 * Created on 2014/08/28, 10:07
 */

#include <cstdio>
#include <algorithm>

using namespace std;

long long int step = -1;
long long int result = 0;

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

int main() {
    while (true) {
       long long int X = 0, Y = 0;
       
       scanf("%d %d", &X, &Y);
       
       if(X == 0 && Y == 0) break;
       
       if (X < Y) {
           X = Y;
       }
       
       result = gcd(X, Y);
             
       printf("%d %d", result, step);
    }
    
    
    
    return 0;
}

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

C++: #include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int cnt;

int gcd(int w,int m){
  if ( m ==0)return w;
  cnt++;
  return gcd(m,w%m);
}

int solve(int *a){
  cnt=0;
  int g = gcd(a[0],a[1]);
  cout << g<<" " << cnt << endl;
}

main(){
  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 <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,m,c,t;
	while(cin >> n >> m,n || m){
		c = 1;
		if(m > n) swap(n,m);
		while(n % m != 0){
			t = n % m;
			n = m;
			m = t;
			++c;
		}
		cout << m << " " << c << endl;
	}
	return 0;
}

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

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

int main(){
    long int cnt;
    unsigned long long a,b;
    unsigned long long x,y,q,r;
    while(1){
        cnt = 0;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        y = min(x,y);
        x = max(x,y);
        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 main()
{
  while(true){
    int X,Y;
    int ans = 0;
    cin >> X >> Y;
    if( X == Y && Y == 0 ) break;
    if( Y > X ) swap( X, Y );

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

    cout << X << ' ' << ans << endl;
  }
  return 0;
}

C++: #include <stdio.h>
int main(){
  long x,y,a;
  int counter=0;

  while(1){
    scanf("%ld %ld",&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;
}