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>
long step;
long enclidean(long a, long b){
                step++;
                long c;
                c = a%b;
                if(c)return enclidean(b,c);
                else return b;
}
int main(){
        long a,b,c;

        while(scanf("%ld %ld",&a,&b), a+b != 0L){
                step = 0;
                if (a > b)
                        c = enclidean(a,b);
                else
                        c = enclidean(b,a);
                putchar('w');
                printf("%d %d\n",c,step);
        }
        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){
		cin>>b;
		if(a==0&&b==0)break;
		long long cnt=0;
		while(b!=0){
			a=a%b;
			swap(a,b);
			cnt++;
		}
		cout<<a<<" "<<cnt<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int Euclid(int a, int b, int& step)
{
	if(b == 0)
	{
		return(a);
	}
	else
	{
		++step;
		return(Euclid(b, a % b, step));
	}
}

void solve()
{
	int a, b;
	while(cin >> a >> b, a || b)
	{
		int step = 0;
		cout << Euclid(a, b, step);
		cout << " " << step << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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