static BigInt collatzLength(long n) { ret collatzLength(bigInt(n)); } static BigInt collatzLength(BigInt n) { BigInt one = BigInt.ONE, three = bigInt(3); BigInt counter = one; while ping (neq(n, one)) { counter = plus(counter, one); if (even(n.intValue())) n = div(n, BigInt.TWO); else n = plus(mul(n, three), one); } ret counter; }