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<stdio.h>
 
int main(){
	int a, b, n, step = 1;
	while(scanf("%d %d", &a, &b) != EOF){
		if(a <= b){
			n = a;
			a = b;
			b = n;
		}
		if(a % b == 0) n = b;
		while(a % b != 0){
			step++;
			if(a % b == 0){
				n = b;
				break;
			}
			a = a % b;
			n = a;
			a = b;
			b = n;
		}
		printf("%d %d\n", n, step);
		step = 1;
	}
	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, ans;

    while (cin >> n >> m, n || m) {
        take = 0;
        ans = (n >= m) ? gcd(n, m) : gcd(m, n);

        cout << ans << " " << take - 1 << endl;
    }

    return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int x,y;
	int n;
	
	while (1){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0){
			break;
		}
		
		n = 0;
		while (y != 0){
			if (x < y){
				x += y;
				y = x - y;
				x -= y;
			}
			
			x %= y;
			x += y;
			y = x - y;
			x -= y;
			
			n++;
			if (y == 0){
				break;
			}
		}
		
		printf("%d %d\n", x, n);
	}
	
	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, tmp;
   if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

    while(cin>>a>>b){
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" "<<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;
       else return gcd(b, a%b);
       counter++;
   }

int main(void){
   int a, b;
    while(cin>>a>>b){
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  long long int x,y,a,b;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    b=0;
    while(1){
      if(y==0)break;
      a=x%y;
      x=y;
      y=a;
      b++;
    }
    cout<<x<<" "<<b<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
 
int main(){
	unsigned long long int a, b, n, step = 1;
	while(scanf("%lld %lld", &a, &b) != EOF){
		if(a < b){
			n = a;
			a = b;
			b = n;
		}
		do{
			step++;
			if(a % b == 0){
				n = b;
				break;
			}
			a = a % b;
			n = a;
			a = b;
			b = n;
		}while(a % b != 0);
		printf("%lld %lld\n", n, step);
		step = 0;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b,r, kouyaku[1001], kazu[1001],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 <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

P check(int a, int b){
  if(b == 0) return P(a, 0);
  else{
    P tmp = check(b, a % b);
    tmp.second += 1;
    return tmp;
  }
}

int main() {
  int a, b;
  while(cin >>a >>b && a){
    if(a < b) swap(a, b);
    P ans = check(a, b);
    cout <<ans.first <<" " <<ans.second <<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int x,y,w,c,a,b;
  while(1){
    c=0;
    cin>>a>>b;
    if(a==0&&b==0){
      break;
    }
    x=max(a,b);
    y=min(a,b);
    while(y){
      x=x%y;
      int temp;
      temp=x;
      x=y;
      y=temp;
      c++;
    }
    cout<<x<<" "<<c<<endl;
  }
}

C++: #include <stdio.h>
main()
{
    int a, b, r, temp;

    while( 1 ) {
        printf( "2つの自然数を指定してください : " );
        if( scanf( "%d, %d",  &a, &b ) != 2 ) break;
        if( a < b ) { temp = a; a = b; b = temp; }
        if( b < 1 ) continue;

        //ユークリッドの互除法により最大公約数を求める
        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        printf( "最大公約数は%d\n", b );
    }
}

C++: #include<stdio.h>
int main(void)
{
	int x,y;
	int cnt;
	int temp;

	scanf("%d %d",&x,&y);
	while(x!=0 && y!=0){
		cnt=0;
		if(x<y){
			temp=x;
			x=y;
			y=temp;
		}
		while(y!=0){
			x=x%y;
			temp=x;
			x=y;
			y=temp;
			cnt++;
		}
	printf("%d %d\n",x,cnt);
	scanf("%d %d",&x,&y);
	}
	return 0;
}

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

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int a,b;
	for(;;){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		if(a<b) swap(a,b);
		int i;
		for(i=0;b!=0;i++){
			int t=a;
			a=b;
			b=t%b;
		}
		printf("%d %d\n",a,i);
	}
}

C++: #include <cstdio>
int ans = 0;
int GCD(int a, int b){
	if(b==0)return a;
	ans++;
	return GCD(b, a%b);
}

int main(){
	int x,y;
	while(scanf("%d %d",&x, &y), x+y){
		ans=0;
		if(x<y)std::swap(x,y);
		int gcd = GCD(x,y);
		printf("%d %d\n",gcd, ans);
	}
}

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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int x, y;
	while(cin >> x >> y && !(x == 0 && y == 0)){
		cnt = 0;
		cout << gcd(x, y) << " ";
		cout << cnt << endl;
	}

	return 0;
}

C++: #include <stdio.h>

void gcd(int x, int y, int c){
  if(y == 0){
    printf("%d %d\n", x, c);
    return;
  }
  gcd(y, x % y, c + 1);
}

int main(){
  int x, y;
  while(scanf("%d%d", &x, &y) && x && y){
    if(x < y){ x += y; y = x - y; x -= y;}
    gcd(x, y, 0);
  }
  return 0;
}

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

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

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


int main(){
  int a,b,X,Y,ans;

  while(true){
    ans = 0;
    cin >> a >> b;
    if( a + b == 0) break;

    X = max(a,b);
    Y = min(a,b);
    int work;
    while(true){
      X = X % Y;
      work = Y;
      Y = X;
      X = work;
      ++ans;
      if(Y == 0) break;
    }

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

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
double dp[200][100];//動的計画法
int main(){
    int a,b,cnt,tmp;
    while(cin>>a>>b,a){
        cnt=0;
        while(b){
            a%=b;
            tmp=b;
            b=a;
            a=tmp;
            cnt++;
        }
        cout<<a<<" "<<cnt<<endl;
    }
}