#include <stdio.h>
#include <strings.h>

int minimum(int a, int b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}

int old_pgcd(int a, int b) {
  int min = minimum(a, b);
  for (int i = min; i >= 2; --i) {
    if ((a % i == 0) && (b % i == 0)) {
      return i;
    }
  }
  return 1;
}

int pgcd(int a, int b) {
  while (b != 0) {
    int rest = a % b;
    a = b;
    b = rest;
  }
  return a;
}

int main() {
  printf("pgcd(%d, %d) = %d\n", 3, 4, pgcd(3, 4));
  printf("pgcd(%d, %d) = %d\n", 5, 15, pgcd(5, 15));
  printf("pgcd(%d, %d) = %d\n", 36, 90, pgcd(36, 90));
  printf("pgcd(%d, %d) = %d\n", 4, 6, pgcd(4, 6));
}
