int pgcd(int a, int b) { int c; if (a > b) { c = a; a = b; b = c; } while (a) { c = a; a = b % a; b = c; } return b; }