Collatz Sequence Length Calculator

Count the steps a number takes to reach 1 in the 3n+1 sequence, plus the highest value it hits.

How it is calculated

Enter a positive whole number. The tool repeats the Collatz rule until the value reaches 1: if the current value is even, halve it; if it is odd, replace it with 3 × value + 1. Each application of the rule is one step. It reports two results: the number of steps and the highest value the sequence reached (the starting number itself counts as a candidate for the peak). Starting at 1 gives 0 steps. Zero, negative numbers and decimals such as 27.9 show no result; they are rejected rather than rounded. Values above 253 (9,007,199,254,740,992) are also rejected, because beyond that point integers can no longer be held exactly. Whole numbers typed with a trailing .0 are accepted.

Worked example

Start with 27. The sequence begins 27, 82, 41, 124, 62, 31, 94, 47, 142, 71, 214 and keeps climbing and falling for a long time. The highest value it touches is 9,232, and 1 is reached after 111 steps, so the tool shows 111 steps and a peak of 9,232. Compare that with 16, which goes 8, 4, 2, 1 in just 4 steps and never rises above its starting value.

Try this example →

Common mistakes

  • Assuming a larger start means more steps. 27 needs 111 steps, while the larger 64 needs only 6 and 28 needs 18.
  • Thinking the tool proves the conjecture. It only follows one starting number down to 1; whether every number does so is still an open question.
  • Entering a decimal or negative number and expecting it to be rounded. Anything that is not a whole number of at least 1 gives no result.
  • Confusing the step count with the length of the sequence. The count is the number of operations, so the list of values has one more entry than the steps, counting the start.
  • Reading the peak as the last value before 1. The peak is the single highest value anywhere in the sequence and is often reached early.

About this calculator

The Collatz conjecture (also called the 3n+1 problem) starts from a simple rule applied repeatedly to any positive integer: if the number is even, divide it by 2; if it’s odd, multiply by 3 and add 1. The conjecture — unproven despite being checked for every integer up into the quintillions — claims that no matter which starting number you pick, this process always eventually reaches 1. This calculator counts how many steps that takes, and tracks the highest value the sequence hits along the way.

Some starting numbers reach 1 in a handful of steps; others, like 27, balloon up past 9,000 before finally descending, which is part of what makes the conjecture so notoriously hard to prove despite its childishly simple rule. It’s a favorite in recreational mathematics and a classic first exercise in programming courses for practicing loops and conditionals, and it remains a genuinely open problem in number theory — Paul Erdős famously said mathematics wasn’t ready for it.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators