Advertisement
Vermiculus

Collatz' Conjecture

Oct 26th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. BigInteger c = new BigInteger("165455345345345361652165161151651654698465165168435135168465132321556846846551");
  2. System.out.println(c);
  3. String c_ = c.toString();
  4. final BigInteger TWO = new BigInteger("2");
  5. final BigInteger THREE = new BigInteger("3");
  6. for(; c.compareTo(BigInteger.ONE) == 1; c_ = c.toString(), System.out.println(c_)) {
  7.     if(Integer.parseInt("" + c_.charAt(c_.length() - 1)) % 2 == 0) {
  8.         c = c.divide(TWO);
  9.     } else {
  10.         c = c.multiply(THREE).add(BigInteger.ONE);
  11.     }
  12. }
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement