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>
#include <cstdio>
using namespace std;

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

int main(void){
   int counter;
   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>
#include<algorithm>
using namespace std;
int main(){
  int x,y;
  while(cin >> x >> y,x){
    int count=0;
    while(y){
      x=x%y;
      swap(x,y);
      count++;
    }
    cout << x << " " << count << endl;
  }
}

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;
     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() {
	int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s;
	kaisuu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (a <= b) {
			r = a;
			a = b;
			b = r;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b!=0){
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i] << " " << kazu[i] << endl;
	}
}

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<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int cnt=0;;
	int i,j,n,m,amari,syo;
	while(1) {
		scanf("%d %d",&n,&m);
		if(n==0 && m==0) break;
		if(n<m) swap(n,m);
		while(1) {
			n=n%m;
			swap(n,m);
			cnt++;
			if(m==0) break;
		}
		printf("%d %d\n",n,cnt);
	}
	return 0;
}

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

int gcd(int a, int b, int cnt);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		int cnt = 0;
		gcd(a, b, cnt);
	}

	return (0);
}

int gcd(int a, int b, int cnt)
{
	if (b == 0){
		cout << a << " " << cnt << endl;
	}
	else {
		return (gcd(b, a % b, cnt + 1));
	}
}

C++: #include<stdio.h>
int main(void)
{
	long long int x,y,temp,X,cnt;
	while(1){
		cnt=0;
		scanf("%lld %lld",&x,&y);
		if(x==0&&y==0)break;
		while(1){
			if(y==0)break;
			cnt++;
			X=x%y;
			x=y;
			y=X;
		}
		printf("%lld %lld\n",x,cnt);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = 50000;
bool p[MAX];
void isPrime(){
  fill(p,p + MAX,true);
  p[0] = p[1] = false;
  rep(i,MAX){
    if(p[i]){
      for(int j = i + i ; j < MAX ; j += i)
	p[j] = false;
    }
  }
} 

int main(void){
  isPrime();
  int n;
  while(cin>>n){

    int i;
 
    for(i = n-1 ; !p[i] ; i --);
    cout<<i<<" ";
    for(i = n+1 ; !p[i] ; i ++);
    cout<<i<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int x,y,temp,X,cnt;
	while(1){
		cnt=0;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		while(1){
			if(y==0)break;
			cnt++;
			X=x%y;
			x=y;
			y=X;
		}
		printf("%d %d\n",x,cnt);
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int x,y,c=0;
  while(cin>>x>>y,x!=0){
   if(x==y){
     cout<<x<<" "<<1<<endl;
     goto at;
   }
   while(y>0){
     x=x%y;
     int s=x;
     x=y;
     y=s;
     c++;
   }
   cout<<x<<" "<<c<<endl;
 at:;
 }
 return 0;   
}

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

int main()
{
	int X,Y,cnt;
	while(cin >> X >> Y, (X||Y))
	{
		cnt = 0;

		if(X<Y) swap(X,Y);
		while(Y!=0)
		{
			cnt++;
			X%=Y;
			swap(X,Y);
		}

		cout << X << " " << cnt << endl;
	}

	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, x;
    while(cin>>a>>b){
        if(a < b){
            x = a;
            a = b;
            b = x;
        }
        if(a == 0 && b == 0)
    return 0;
        counter = 0;
        cout<<gcd(a,b)<<' ’;
       cout<<counter<<endl;
    }
    return 0;

C++: #include<iostream>
#include<map>
using namespace std;
int gcd(int x, int y);
int euc(int x, int y, int f);
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    if(n<m){int c = n; n = m; m = c;}
    cout <<gcd(n,m)<<" "<<euc(n,m,0)<<endl;
  }
  return 0;
}
int gcd(int x, int y){
  if(y == 0){return x;}
  return gcd(y,x%y);
}
int euc(int x, int y, int f){
  if(y == 0){return f;}
  f++;
  return euc(y,x%y,f);
}

C++: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b;
  while (cin >> a >> b, a) {
    if (a < b) swap(a, b);
    pii g = gcd(a, b);
    cout << g.first << " " << g.second << endl;
  }

  return 0;
}

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

int gcd(int a, int b, int step);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		int step = 0;
		gcd(a, b, step);
	}

	return (0);
}

int 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<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>
using namespace std;

int main(){
	int x, y, tmp, count;
	while(cin>>x>>y, x&&y){
		if(x<y){
			tmp=x;
			x=y;
			y=tmp;
		}
		count=0;
		while(y!=0){
			x %= y;
			tmp=x;
			x=y;
			y=tmp;
			count++;
		}
		printf("%d %d\n", x, count);
	}
	return 0;
}

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


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

  while(scanf("%d %d", &a, &b) != EOF)
  {

   i = 0;

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