Collatz Sequence Calculator

Enter a whole number (1 or greater) to generate its Collatz sequence.

How it is calculated

Starting from your whole number n, the tool repeats one rule until it reaches 1: if n is even, n → n ÷ 2; if n is odd, n → 3n + 1. It records every value, counts the steps (the number of times the rule was applied, not the number of terms) and keeps the largest value reached as the peak.

The input must be a whole number of 1 or more; zero, negatives and decimals give no result, and neither does a number above 9 × 1015. Starting at 1 gives zero steps. Only the first 200 terms are printed, followed by a note with the total number of terms. If a run did not reach 1 within 10,000 steps, or the arithmetic would overflow, nothing is shown rather than an unfinished sequence. Whether every start number really ends at 1 is the unproved Collatz conjecture; the tool simply follows the rule.

Worked example

Start with n = 7. It is odd, so 7 → 3 × 7 + 1 = 22. Then 22 → 11, and 11 is odd: 3 × 11 + 1 = 34. Next 34 → 17, 17 → 52, then 52 → 26 → 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1. The tool prints 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1: 17 terms, 16 steps, and a peak value of 52.

Try this example →

Common mistakes

  • Counting the terms in the list as the steps. The sequence has one more term than steps, because the starting number is included: 17 terms, 16 steps for 7.
  • Entering zero, a negative number or a decimal such as 6.5. Only whole numbers from 1 upward produce a result; anything else shows nothing.
  • Expecting a larger starting number to give a longer sequence. Step counts jump around: 27 takes 111 steps and climbs to 9,232, while 32 takes only 5.
  • Treating the output as a proof of the conjecture. A run only confirms the numbers you test.
  • Reading the printed list as complete for long runs. After 200 terms it is cut short, and the note gives only the total term count (837799 has 525 terms).

About this calculator

The Collatz conjecture (also called the 3n+1 problem) proposes a deceptively simple rule: starting from any positive whole number, if it's even, halve it; if it's odd, triple it and add one; repeat. The conjecture — unproven despite being checked for every number up to enormous limits — claims this process always eventually reaches 1. This calculator runs the rule for any starting number and shows the full sequence, the total number of steps, and the highest value reached along the way.

The problem is a favorite in recreational and number theory mathematics because it's trivial to state but has resisted proof for nearly a century — mathematician Paul Erdős reportedly said mathematics wasn't ready for it. Students and hobbyists use a Collatz calculator to explore how wildly the sequence length and peak value can vary between nearby starting numbers, and educators use it as an approachable entry point into open problems in mathematics.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Starting values near each other can behave very differently. The tool shows 1024 reaching 1 in 10 steps, while 871 needs 178 steps and climbs to 190,996, and 27 needs 111 steps with a peak of 9,232. It refuses to print a run that does not finish within 10,000 steps, so it never shows a partial path. Which start below 1,000 gave you the longest trip?

Popular calculators

All Calculators