SHOW:
|
|
- or go back to the newest paste.
| 1 | - | BigInteger c = new BigInteger("165455345345345361652165161151651654698465165168435135168465132321556846846551");
|
| 1 | + | final BigInteger TWO = new BigInteger("2");
|
| 2 | - | System.out.println(c); |
| 2 | + | final BigInteger THREE = new BigInteger("3");
|
| 3 | - | String c_ = c.toString(); |
| 3 | + | BigInteger c = new BigInteger("12345678901234567890");
|
| 4 | - | final BigInteger TWO = new BigInteger("2");
|
| 4 | + | System.out.println(c); |
| 5 | - | final BigInteger THREE = new BigInteger("3");
|
| 5 | + | for(; c.compareTo(BigInteger.ONE) == 1; System.out.println(c)) {
|
| 6 | - | for(; c.compareTo(BigInteger.ONE) == 1; c_ = c.toString(), System.out.println(c_)) {
|
| 6 | + | if(c.testBit(0)) { // if odd
|
| 7 | - | if(Integer.parseInt("" + c_.charAt(c_.length() - 1)) % 2 == 0) {
|
| 7 | + | c = c.multiply(THREE).add(BigInteger.ONE); // c = 3 * c + 1 |
| 8 | - | c = c.divide(TWO); |
| 8 | + | } else { // even
|
| 9 | - | } else {
|
| 9 | + | c = c.divide(TWO); // c = 2 * c |
| 10 | - | c = c.multiply(THREE).add(BigInteger.ONE); |
| 10 | + | } |
| 11 | - | } |
| 11 | + | } |
| 12 | - | } |
| 12 | + |