friend bigint gcd(const bigint &a, const bigint &b) {
   return b.isZero() ? a : gcd(b, a % b);
 }