Collatz Sequence Generator

Generate the Collatz (3n+1) sequence for any starting integer

Generate the full Collatz sequence for any positive starting integer: halve even numbers, triple-plus-one odd numbers, until you reach 1. Shows every step, the total stopping time, and the peak value. Runs in your browser using BigInt. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the Collatz conjecture?

The Collatz conjecture states that starting from any positive integer and repeatedly applying the rule — halve if even, otherwise triple and add one — you will always eventually reach 1. It is unproven for all numbers but verified for vast ranges.

The Collatz sequence (the “3n+1 problem”) follows a deceptively simple rule yet produces wildly unpredictable paths before always — as far as anyone has ever checked — settling on 1. This tool generates the complete sequence for any starting integer and reports its key statistics.

How it works

From a starting value n, repeat until you reach 1:

if n is even:  n = n / 2
if n is odd:   n = 3 × n + 1

So n = 6 produces 6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1. The number of steps to first reach 1 is the stopping time, and the largest value seen along the way is the peak. BigInt is used so that even sequences that spike into very large numbers stay exact.

Two famous examples to try

Starting from 27: One of the most-cited examples. The sequence takes 111 steps and reaches a peak value of 9232 before eventually descending to 1. For a starting number as small as 27, 111 steps and a peak of 9232 seem absurdly large — this is typical of the conjecture’s unpredictability.

Starting from 871: This produces an even longer journey than 27 in terms of peak value, soaring much higher before collapsing. Try it and compare with 27 — smaller starting numbers can have longer, wilder trajectories than larger ones.

What makes this an open problem

The Collatz conjecture — that every positive integer eventually reaches 1 — is one of mathematics’ most famous unsolved problems. It has been verified computationally for extremely large ranges of starting values, yet no general proof exists. The difficulty is that the rule combines multiplicative and additive operations in a way that resists standard number-theoretic tools. Mathematicians have described it as “the simplest impossible problem.”

The sequence is also called hailstone numbers because values rise and fall erratically, like ice crystals caught in updrafts before eventually falling, and Syracuse numbers after the American university where research was concentrated in the mid-20th century.

Patterns to notice

  • Powers of 2 always produce the shortest sequences: each step is a halving, so 64 → 32 → 16 → 8 → 4 → 2 → 1 in exactly 6 steps.
  • Numbers that are one less than a power of 2 tend to have very long trajectories.
  • Even numbers take only one step before halving; odd numbers always increase before the next reduction.
  • The stopping time is unrelated to the size of the starting number in any simple way — 27 takes 111 steps while 128 takes only 7.

Use the tool to explore different starting values and compare their stopping times and peak values side by side.