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

int N;
int Ns, Nl;
int num[4];
int S[4], L[4];
int result;

int main() {
    while (true) {
        result = 0;
        cin >> N;
        
        if (!N) break;            
        
        if (N != 6174) {
            num[0] = N / 1000;
            N %= 1000;
            num[1] = N / 100;
            N %= 100;
            num[2] = N / 10;
            N %= 10;
            num[3] = N;
            
            while (true) {
                Ns = 0; Nl = 0;
                int judge = 0;
                for (int i = 0; i < 4; i++) {
                    if (num[0] == num[i]) judge++;
                }

                if (judge == 4) {
                    cout << "NA" << endl;
                    break;
                }

                sort(num, num + 4);
                for (int i = 0; i < 4; i++) {
                    S[i] = num[i];
                }

                Ns += S[0] * 1000;
                Ns += S[1] * 100;
                Ns += S[2] * 10;
                Ns += S[3];

                sort(num, num + 4, greater<int>());
                for (int i = 0; i < 4; i++) {
                    L[i] = num[i];
                }

                Nl += L[0] * 1000;
                Nl += L[1] * 100;
                Nl += L[2] * 10;
                Nl += L[3];

                N = Nl - Ns;

                num[0] = N / 1000;
                N %= 1000;
                num[1] = N / 100;
                N %= 100;
                num[2] = N / 10;
                N %= 10;
                num[3] = N;

                result++;

                if(num[0] == 6 && num[1] == 1 && num[2] == 7 && num[3] == 4) {
                    cout << result << endl;
                    break;
                }
            }
        }
        else cout << 0 << endl;
        
    }
    
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int ans;
int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  ++ans;
  return gcd(b,a%b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b&&a&&b){
    ans = 0;
    int k = gcd(a,b);
    cout << k <<" " << ans << endl;
  }
  return 0;
}

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

int main(){
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0){break;}
		if(a<b)swap(a,b);

		int count=0;
		while(b!=0){
		a=a%b;
		swap(a,b);
		count++;

		}
	cout<<a<<" "<<count<<endl;
	}
	return 0;
}

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

int mygcd ( int a, int b, int &S ) {

    if ( b == 0 ) {
        return ( a );
    }
    S++;

    return ( mygcd ( b, a % b, S ) );

}
int main()
{
    int A, B;
    int S = 0;

    cin >> A >> B;

    int div = mygcd(A, B, S);

    cout << div << " " << S << endl;

    return ( 0 );
}

C++: #include<bits/stdc++.h>
using namespace std;
int N,M;
int main()
{
	while(true){
		scanf("%d%d",&N,&M);
		if(N<M)swap(N,M);
		if(N==0&&M==0)return 0;
		int cou=0;
		while(true){
			cou++;
			int M1=N%M;
			int N1=M;
			N=N1;M=M1;
			if(M==0)break;
		}
		printf("%d %d\n",N,cou);
	}
}

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

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

int main() {
	int x, y;
	while(cin >> x >> y && (x || y)){
		N = 0;
		int a = max(x, y);
		int b = min(x, y);
		int ans = gcd(a, b);
		
		cout << ans << " " << N << endl;
	}
	return 0;
}

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

int main(){
	while(1){
	int a,b,c;
	cin>>a>>b;
	if(a==0 && b==0){break;}
	c=0;
	t=0;
	int count=0;
	while(b!=0){
	c=a%b;
	a=c;
	swap(a,b);

	count++;
	}
	cout<<a<<" "<<count<<endl;
	}
}

C++: #include <stdio.h>
int main(void) {
	long a1, a2, x, y;
	int amari,i=0;
	scanf("%ld %ld", &a1, &a2);	//1. 2number
	if(a1==0 && a2==0)break;
	
	if(a1<a2){
		
		x = a2;
		y = a1;
	}	
	while(amari =! 0){
		amari = x % y;
		x = y;
		y = amari;
                i++;
	
	}
	
	printf("%ld %ld\n", x, i);
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
	for (int i = 0; i < 1000; i++){
		int a,b;

		cin >> a >> b;

		if (a == 0 && b == 0)
			break;

		int j,r,COUNT = 1;

		if (b > a){
			j = a;
			a = b;
			b = j;
		}

		while((r = a % b) != 0)
			{ a = b; b = r; COUNT++;}

		cout << b << " " <<COUNT << endl;
	}

	return 0;
}

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

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

void greatestCommonDivisor(int x, int y);

int main(){
	int a, b;
	while(scanf("%d %d", &a, &b)){
		if(a == 0 and b == 0) break;
		greatestCommonDivisor(a, b);
	}
	return 0;
}

void greatestCommonDivisor(int x, int y){
	int temp, count = 0;
	while(true){
		x %= y;
		if(x == 0) break;
		temp = x;
		x = y;
		y = temp;
		count++;
	}
	printf("%d %d\n", y, count + 1);
}

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

int main(){

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

  while(1)
    {
      cnt=0;
      cin >> x >> y;

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

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

      while(1)
	{
	  x = x%y;
	  swap(x,y);
	  
	  cnt++;
	  if(y == 0)break;
	}
	
      cout << x << " " << cnt << endl;
    }
}

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

int euclid(int a, int b) {
	int cnt = 0;
	while (a != 0 && b != 0) {
		if (a >= b) { a = a%b; }
		else { b = b%a; }
		cnt++;
	}
	return cnt;
}

int main() {
	int x, y;
	while (true) {
		cin >> x >> y;
		if (x + y == 0) { break; }
		cout << __gcd(x, y) << ' ' << euclid(x, y) << endl;
	}
}