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.
Example and tips
27 is a famous example: it takes 111 steps and climbs all the way to 9232
before crashing back down to 1. Watch how even small starting numbers can have
long, jagged trajectories — that erratic, hailstone-like behaviour is exactly
what makes the unproven Collatz conjecture so intriguing.