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