Collatz Conjecture Calculator: Tracing the 3n+1 Sequence to 1
About the Author

A Collatz conjecture calculator exists because 27 is a trap. The rule looks like something you could do on the back of an envelope — halve it if it’s even, triple it and add one if it’s odd, repeat until you hit 1 — and for 26 that’s ten quick steps. Start at 27 instead and the sequence climbs to 9,232, wanders for a while, and only reaches 1 on step 111. One arithmetic slip anywhere in those 111 lines and every number after it is wrong, with nothing to warn you. That’s the whole reason to automate it.
The tool above runs the sequence on exact integers of any size, then reports the things a hand trace rarely bothers to record: the peak, the step where the value first drops back below where it started, and how the moves split between tripling and halving. Below, the algorithm in full, the numbers that set records, and the two step-counting conventions that make different calculators disagree about the same input.
The Rule, and the One Thing Nobody Has Proved
Pick a positive whole number. If it’s even, divide by 2. If it’s odd, multiply by 3 and add 1. Repeat.
Take 6: even, so 3. Odd, so 10. Even, so 5, then 16, 8, 4, 2, 1. Eight steps and done. The values rise and fall on the way, which is why they’re called hailstone numbers — a hailstone gets tossed up and down inside a storm cloud before it finally falls.
The conjecture, posed by Lothar Collatz in 1937, is the claim that every positive integer eventually reaches 1. Nobody has proved it. Nobody has found a counterexample either, and the search has been thorough: distributed computing projects have verified every start up to at least 268, about 2.95 × 1020 numbers. Terence Tao proved in 2019 that almost all starting values eventually drop below any function that grows to infinity — the strongest result so far, and still short of the conjecture itself. Paul Erdős summarised the state of play best: “Mathematics is not yet ready for such problems.”
This matters for how you read any output. When the calculator says 27 reaches 1 in 111 steps, that is a verified fact about 27. It is not evidence about numbers nobody has tried.
Following 27 All the Way Up and Back Down
27 is the standard demonstration because it’s small enough to look harmless and long enough to be genuinely annoying. Here’s the opening:
Notice the pattern in those first moves: odd, then a single halving, then odd again. 27 → 82 → 41 means one tripling bought back only one division, so the value went from 27 to 41 in two steps. That is the engine of the climb. It keeps happening until the sequence tops out at 9,232 on step 77 — 342 times the starting value — and then a long run of halvings brings it home on step 111.
Two counts explain the whole shape. 27’s path contains 41 tripling steps and 70 halving steps. Since each tripling multiplies by roughly 3 and each halving divides by 2, the sequence survives only if the halvings outweigh the triplings — specifically if there are more than log₂3 ≈ 1.585 halvings per tripling. 27 runs at 70 ÷ 41 = 1.71, barely above break-even, so it takes forever to descend. A typical number runs closer to 2.0 halvings per tripling and finishes much faster. That single ratio, shown in the calculator’s blue panel, predicts a long path better than the size of the starting number does.
Here’s the check that makes it concrete. With 70 halvings and 41 triplings, ignoring the +1 each time, the trajectory multiplies the start by 3⁴¹ and divides it by 2⁷⁰. So 2⁷⁰ ÷ 3⁴¹ ≈ 32, which is the same ballpark as 27 — the sequence had precisely enough halving to cancel the number out. Try it on 837,799: 329 halvings, 195 triplings, and 2³²⁹ ÷ 3¹⁹⁵ ≈ 1.00 × 10⁶ against a start of 837,799. Almost exact. The “+1” is small enough that this accounting works.
The Numbers That Hold Records
A record-setter is a start whose path is longer than every smaller start’s. There are only 43 of them below a million, and the jumps between them are wild. Here are the ones worth knowing, all confirmed by the record hunt in the calculator above:
| Starting number | Steps to 1 | Highest value reached | Why it’s notable |
|---|---|---|---|
| 27 | 111 | 9,232 | Jumps from 25’s 23 steps — the biggest early leap |
| 703 | 170 | 250,504 | Peaks at 356× its start |
| 6,171 | 261 | 975,400 | Longest path under 10,000 |
| 77,031 | 350 | 21,933,016 | Longest path under 100,000 |
| 837,799 | 524 | 2,974,984,576 | Longest path under 1,000,000 |
| 63,728,127 | 949 | 966,616,035,460 | Longest path under 100,000,000 |
Read the middle column against the first and the headline result falls out: each tenfold jump in the search range adds only about 170 steps to the record — 261 under ten thousand, 350 under a hundred thousand, 524 under a million. Path length grows like the logarithm of the starting number, not like the number itself. That is why a 30-digit start still finishes in a few hundred steps rather than a few trillion.
The peak column behaves completely differently, and this is where intuition fails. 159,487 is not a record-setter — it reaches 1 in a modest 183 steps — yet it climbs to 17,202,377,752, over 107,000 times its starting value and nearly six times higher than anything 837,799 touches on a path almost three times as long. Height and length are separate phenomena. If you are writing code to explore this, that distinction decides your integer type: 32-bit arithmetic silently overflows on starts well under a million, which is exactly why the calculator above uses arbitrary-precision integers throughout. Anyone doing similar work by hand should reach for a scientific notation calculator once the values pass ten digits.
What a Collatz Conjecture Calculator Counts as One Step
Ask one tool for 27 and get 111. Ask another and get 70. Both are right, because they count differently, and this trips up more people than any other part of the problem.
An odd number always produces an even number: 3n + 1 with n odd is even, guaranteed, so the very next move is forced to be a halving. The shortcut form merges those two into one and uses n → (3n + 1) / 2 for odd values. Nothing about the arithmetic changes; the intermediate even number just never gets written down. For 27 that removes all 41 tripling steps from the count and leaves 70.
| Convention | Odd rule | Steps for 27 | Usual home |
|---|---|---|---|
| Standard | 3n + 1 | 111 | Textbooks, OEIS A006577, most puzzles |
| Shortcut | (3n + 1) / 2 | 70 | Research papers, cycle analysis |
Use standard unless a source tells you otherwise — it is what “total stopping time” means in the literature and what the OEIS sequence records. Switch to shortcut when you are studying the structure of the map itself, where the redundant even values are noise. The selector above the chart flips between them so you can see both counts for the same input.
A second, subtler mismatch: stopping time and total stopping timeare different quantities. Total stopping time is the steps to reach 1. Plain stopping time is the steps until the value first falls below where it started. For 27 those are 111 and 96. For 97 they are 118 and 3 — 97 drops under itself almost immediately, then spends the next 115 steps wandering, and its peak is 9,232, the same summit 27 reaches. The two trajectories merge and finish together. Every Collatz path eventually joins one of a small number of highways down.
Patterns You Can Predict Without Running Anything
Some starting values are decided before you compute a thing:
- Powers of two are the fastest possible. 1,024 halves ten times and stops. Any 2k takes exactly k steps with zero triplings — the only starts where the ratio panel shows no odd steps at all. Check any candidate with a power calculator if the exponent isn’t obvious.
- Doubling a number adds exactly one step. 27 takes 111, so 54 takes 112, 108 takes 113, and so on forever. The first move on an even number is a halving, which lands you straight back on the original path. This is why record tables are dominated by odd numbers.
- Numbers of the form 4k + 1 collapse quickly. An odd n ≡ 1 (mod 4) gives 3n + 1 divisible by 4, so you get two halvings for one tripling and the value drops below n almost at once. 97 is the poster child — three steps to fall under itself. The slow starts are the ones congruent to 3 mod 4, like 27, 703 and 6,171, where 3n + 1 is only divisible by 2 once.
- Consecutive numbers often share a path length. 54 and 55 both take 112 steps; they merge after a couple of moves and finish together. Runs of three, four and five consecutive starts with identical step counts are common — a consequence of how quickly trajectories join.
The third rule is worth internalising because it converts a parity question into a prediction. Work out n mod 4 with a modulo calculator and you already know whether the next excursion climbs or collapses. It also explains the record table: 27, 703, 6,171, 77,031 and 837,799 are all 3 mod 4.
Four Ways People Get Collatz Results Wrong
Counting the starting number as a step. The sequence for 6 has nine numbers in it — 6, 3, 10, 5, 16, 8, 4, 2, 1 — but eight steps, because a step is a move between numbers. Off-by-one here is the single most common source of “my answer doesn’t match”, and it is why the calculator labels the step column starting at 0.
Silent integer overflow. A 32-bit signed integer maxes out at 2,147,483,647. Start at 159,487 and the trajectory sails past that on its way to 17.2 billion, wrapping around to a negative number and producing a sequence that never terminates or terminates at the wrong place. The program does not crash; it just lies. Use 64-bit integers at minimum, and arbitrary precision if you intend to go past ten digits.
Expecting the peak to scale with the starting number. It doesn’t. 27 peaks at 342× its start, 703 at 356×, and 159,487 at 107,857×. There is no formula for how high a trajectory goes, and the only known way to find out is to run it.
Assuming a proof exists somewhere. It doesn’t, and this genuinely surprises people who meet the problem in a programming course. The Wikipedia article on the Collatz conjecture catalogues the partial results, and OEIS sequence A006577 lists the step counts term by term if you want to check the tool against a reference. What has been ruled out is narrow but real: any counterexample cycle other than 4 → 2 → 1 must contain well over 100 billion terms, and any divergent trajectory has to start above 268.
One last practical note. If you are using this as a programming exercise — it is a classic one — memoise the results. Computing every path from 1 to a million naively repeats the same tail calculations tens of millions of times; caching each number’s step count as you go turns a multi-second job into about 60 milliseconds, which is exactly the trick the record hunt above uses. The same idea shows up whenever a recurrence relation gets evaluated repeatedly, and it is the difference between a demo that feels instant and one that hangs the browser tab.



