Skip to content
100% local

Collatz sequence

Generate the Collatz (3n+1) sequence for a number and see how many steps it takes to reach 1.

Input
Output

Collatz sequence

Enter a positive whole number and this tool generates its Collatz sequence — repeatedly halving even numbers and applying 3n+1 to odd ones until the sequence reaches 1. It is also known as the hailstone sequence, because values rise and fall unpredictably before crashing down, and it is the basis of the still-unproven Collatz conjecture: that every positive integer eventually reaches 1 this way.

Turn on "Support very large numbers" to compute exact results for starting numbers beyond standard 64-bit precision, using arbitrary-precision arithmetic instead of rounding. "Show calculation steps" prints every individual halving or 3n+1 operation instead of just the final list, which is useful for checking the math by hand or for teaching the rule. "Batch mode" accepts one starting number per line and prints a one-line summary — step count, peak value, and the peak-to-start ratio — for each. Output format switches the sequence between arrow-separated, comma-separated and one-value-per-line.

Sequences can grow far larger than their starting number before collapsing — 27 takes 111 steps and peaks at 9,232 — so the tool tracks the peak value and its ratio to the starting number, with the ratio's decimal precision under your control. A safety limit stops any sequence that runs unexpectedly long, and generated output is capped so a huge batch can never freeze the tab.

Everything runs locally in your browser — no number you enter is ever sent anywhere. Copy the result, download it as a .txt file, or send the output back into the input to keep exploring from wherever the sequence leads.

FAQ

What is the Collatz conjecture?
It is the unproven claim that starting from any positive integer and repeatedly applying "halve if even, 3n+1 if odd" always eventually reaches 1. It has been checked for enormous ranges of numbers but never proven for all of them.
Why does the sequence sometimes get much larger than the starting number?
The 3n+1 step can more than triple an odd number before the next halving steps bring it back down, so the sequence often peaks well above its starting value before eventually collapsing to 1.
What does "Support very large numbers" change?
With it off, calculations are limited to standard safe-integer precision and very large starting numbers are rejected. Turning it on switches to exact arbitrary-precision arithmetic so much larger numbers compute correctly.
What happens if a sequence never reaches 1?
No number has ever been found that fails to reach 1, but the tool still enforces a safety limit on the number of steps, so it stops cleanly instead of running indefinitely if that were ever to happen.
Is my input uploaded anywhere?
No. The sequence is calculated entirely in your browser — the numbers you enter never leave your device.