What this calculator does
The Collatz rule is about as simple as a rule gets. Take a positive whole number. If it is even, halve it. If it is odd, triple it and add one. Repeat. Every starting value anyone has ever tested eventually arrives at 1, and yet nobody has proved that every value must.
What makes the problem interesting is how unruly the path is. Modest starting numbers can take hundreds of steps and climb into the hundreds of thousands before collapsing back down, and two neighbouring numbers can behave nothing alike. This calculator runs the sequence, counts the steps and records the highest value reached on the way.
The formula
Starting from the number entered, one of two rules is applied at each step: halve the value if it is even, or multiply by three and add one if it is odd. This repeats until the value reaches 1. The steps taken are counted as the stopping time, and the largest value seen anywhere in the sequence is tracked separately. The run is abandoned after 100,000 steps if 1 has not been reached, a limit no tested starting value has ever come close to needing.
| Term | Meaning |
|---|---|
| Stopping time | The number of steps taken to reach 1 from the starting value. |
| Peak value | The largest number reached anywhere in the sequence, which is often far above the starting value. |
| 3n + 1 step | The rule applied to odd numbers, the only step in the process that makes the value larger. |
| Conjecture | A statement believed true and supported by evidence, but not proved. The Collatz conjecture is that every positive starting value reaches 1. |
The inputs explained
| Field | What to enter |
|---|---|
| Starting number (positive integer) | The number to start from, a positive whole number. Anything entered is rounded and its sign ignored. |
When to use it
Exploring how erratic the sequences are
Running several nearby starting values in turn is the quickest way to see that stopping time has no smooth relationship to the starting number, which is the feature that has kept the problem open.
Checking a hand-worked sequence
The rule is easy to apply and easy to slip up on, particularly over a long run. Comparing a hand-written sequence against the full list here catches a dropped or doubled step.
Teaching iteration and loops
The Collatz sequence is a standard first exercise in writing a loop with a condition inside it, and having the correct step count and peak value to check against makes the exercise self-marking.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How long does the 3n + 1 sequence take from different starting numbers?
Five starting values, including a neighbouring pair, and what each takes to reach 1.
| Starting number | Stopping time (steps to reach 1) | Peak value reached | Total terms |
|---|---|---|---|
| 6 | 8 | 16 | 9 |
| 7 | 16 | 52 | 17 |
| 27 | 111 | 9,232 | 112 |
| 97 | 118 | 9,232 | 119 |
| 871 | 178 | 190,996 | 179 |
Questions
Has the Collatz conjecture been proved?
No. It has been checked by computer for every starting value up to extremely large bounds without a single exception, but verification is not proof, and no argument covering all numbers has been found. It is one of the best known open problems in mathematics precisely because it is so easy to state.
What is the stopping time?
The number of steps taken to get from the starting value to 1. Halving counts as a step and the 3n + 1 rule counts as a step, so the stopping time is one less than the total number of terms in the sequence.
Why does every sequence end 4, 2, 1?
Because 1 is odd, the rule sends it to 4, which halves to 2 and then to 1 again. That three-term loop is where every sequence lands, and reaching any power of 2 anywhere along the way guarantees a clean run of halvings straight down into it.
Can the sequence go up forever?
Nobody knows, and that is the conjecture. It would also be enough to find a loop other than 4, 2, 1. Neither has ever been observed, but neither has been ruled out either.
For another number-theory curiosity with a simple rule and surprising behaviour, see the perfect number calculator. For a sequence that grows predictably instead, see the Fibonacci sequence calculator.