Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final BigInteger TWO = new BigInteger("2");
- final BigInteger THREE = new BigInteger("3");
- BigInteger c = new BigInteger("12345678901234567890");
- System.out.println(c);
- for(; c.compareTo(BigInteger.ONE) == 1; System.out.println(c)) {
- if(c.testBit(0)) { // if odd
- c = c.multiply(THREE).add(BigInteger.ONE); // c = 3 * c + 1
- } else { // even
- c = c.divide(TWO); // c = 2 * c
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement