static ItIt collatzSequence(long n) { ret collatzSequence(bigInt(n)); } static ItIt collatzSequence(BigInt _n) { ret new ItIt { BigInt three = bigInt(3); BigInt n = _n; public bool hasNext() { ret neq(n, BigInt.ONE); } public BigInt next() { if (even(n.intValue())) n = div(n, BigInt.TWO); else n = plus(mul(n, three), one); ret n; } }; }