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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

int gcd(int x, int y, int &t) {
  if (x < y) swap(x, y);
  for (; y; t++) {
    x %= y;
    swap(x, y);
  }
  return x;
}

void solve() {
  int a, b;
  while (cin >> a >> b, a) {
    int t = 0;
    cout << gcd(a, b, t) << ' ' << t << endl;
  }
}

C++: #include <stdio.h>

int c;

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)
    gcd(x, y, 0);
  return 0;
}

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