BigInt newtonIteration(BigInt n, BigInt x0) { var x1 = (BigInt.from(n / x0) + x0) >> 1; if (x0 == x1 || x0 == (x1 - BigInt.from(1))) { return x0; } return newtonIteration(n, x1); }