// (JAVA) import java.math.BigInteger; public class A276665 { public static void main(String[] args) { BigInteger s, m, M, S, i, j; M = S = BigInteger.valueOf(-1); i = BigInteger.ONE; while (true) { s = BigInteger.ZERO; j = m = i; while (!j.equals(BigInteger.ONE)) { s = s.add(BigInteger.ONE); if (!j.testBit(0)) j = j.shiftRight(1); else j = j.multiply(BigInteger.valueOf(3)).add(BigInteger.ONE); if (j.compareTo(m) > 0) m = j; } if (s.compareTo(S) > 0 && m.compareTo(M) > 0) System.out.println(i); if (s.compareTo(S) > 0) S = s; if (m.compareTo(M) > 0) M = m; i = i.add(BigInteger.ONE); } } }