"***********************************************************************************************"

The Collatz Conjecture

For any positive integer n, the Collatz sequence is defined as follows:

    If n is even:
        Divide it by 2.
    If n is odd:
        Multiply it by 3 and add 1.

    Repeat the process with the new value of n.

The conjecture states that no matter what positive integer you start with, the sequence will always eventually reach 1.

For example, consider n = 6:

    6 is even,  6÷2=3
    3 is odd,   3×3+1=10
    10 is even, 10÷2=5
    5 is odd,   5×3+1=16.
    16 is even, 16÷2=8.
    8 is even,  8÷2=4.
    4 is even,  4÷2=2.
    2 is even,  2÷2=1.

*******************************************************
*******************************************************

Enter an integer greater than 1 below to see how many steps it takes to get to the the number "1". The arrow keys work. For example, if you enter 32, you get 5; press the "down" arrow on your keyboard, or the "down" arrow on the input box (below), and see that it takes 106 steps for 31 to get to 1.

The selected number is undefined

*******************************************************
*******************************************************

Here's the code that generates the Collatz sequence on this page:

  var log = console.log;
  var dF3x = () => {};

  function M(x) {
    return function go(func) {
      if (func === dF3x) return x;
      else x = func(x);
      return go;
    };
  }

var n;
var m;

var collatz = function collatz (n) {
    m = M([n, 0]);
    m(f);
}
var out = "";

function f (d) {
      if (d[1] === 0) log("testing the number", d[0]);
      d[1] = d[1] += 1;
      if (d[0] % 2 === 0) d = [d[0]/2, d[1]]
      else if (d[0] % 2 !== 0) d = [d[0]*3 + 1, d[1]]
      if (d[0] !== 1) f(d)
      else {
          d[1] = d[1];
          out = "The number of steps was " + d[1];
      }
}

function getInput (event) {
    n = event.target.value;
}

Here are some results:

testing the number 10
The number of steps is 6

testing the number 100
The number of steps is 25

testing the number 1000
The number of steps is 111

testing the number 10000
The number of steps is 29

testing the number 100000
The number of steps is 128

testing the number 1000000
The number of steps is 152

testing the number 10000000
The number of steps is 145

testing the number 100000000
The number of steps is 107

testing the number 1000000000
The number of steps is 100

testing the number 10000000000
The number of steps is 124

testing the number 100000000000
The number of steps is 347

testing the number 1000000000000
The number of steps is 146

Even n = 9**100 finishes in fewer than 1000 steps, as shown below.

testing the number 2.6561398887587478e+95
d is [ 1.3280699443793739e+95, 1 ]
d is [ 6.6403497218968695e+94, 2 ]
d is [ 3.3201748609484348e+94, 3 ]
d is [ 1.6600874304742174e+94, 4 ]
d is [ 8.300437152371087e+93, 5 ]
d is [ 4.1502185761855434e+93, 6 ]
d is [ 2.0751092880927717e+93, 7 ]
d is [ 1.0375546440463859e+93, 8 ]
d is [ 5.1877732202319293e+92, 9 ]
d is [ 2.5938866101159647e+92, 10 ]
d is [ 1.2969433050579823e+92, 11 ]
...
d is [ 1364, 578 ]
d is [ 682, 579 ]
d is [ 341, 580 ]
d is [ 1024, 581 ]
d is [ 512, 582 ]
d is [ 256, 583 ]
d is [ 128, 584 ]
d is [ 64, 585 ]
d is [ 32, 586 ]
d is [ 16, 587 ]
d is [ 8, 588 ]
d is [ 4, 589 ]
d is [ 2, 590 ]
d is [ 1, 591 ]
The number of steps is 591