Skip to content

Collatz Conjecture (3n+1)

The Collatz Conjecture, also known as the 3n+1 conjecture, is one of the most fascinating open problems in contemporary mathematics. Despite its extraordinarily simple formulation, it has remained unsolved for more than eighty years.

Statement of the conjecture:
Given a positive integer nn, apply the following iterative procedure:

  • If nn is even, divide by 2: nn/2n \to n/2
  • If nn is odd, compute 3n+13n+1: n3n+1n \to 3n+1

The conjecture asserts that, regardless of the initial value of nn, the sequence will always reach the value 1 (and then enter the cycle 1 → 4 → 2 → 1).

The tool below visualizes the progression of the Collatz sequence for a chosen starting number. Points are colored according to their mathematical properties, and segments change color depending on the direction of the variation.

0.5x

In the simulator, each visual element conveys didactic information:

ElementColorMeaning
Starting point🟢 GreenThe number you start with
Even number🔴 RedAn even number in the sequence
Odd number🔵 BlueAn odd number in the sequence
Ending point🟢 GreenWhen 1 is reached
Ascending segment▬ YellowValue increases (nn odd: 3n+13n+1)
Descending segment▬ OrangeValue decreases (nn even: n/2n/2)
  1. Enter a number (1–100) in the input box or press “Random Number” to generate one.
  2. Press “Calculate” to start the animation of the sequence.
  3. Adjust the speed with the slider during animation (in real-time).
  4. During animation you can:
    • Modify the input for a new number (does not interrupt the current animation)
    • Press “Random Number” to generate a new value (does not interrupt the current animation)
    • Press “Calculate” if the number has changed: this will stop the animation and restart from the beginning
    • Press “Calculate” without changes: the animation continues undisturbed
  • The horizontal axis represents the number of steps in the algorithm.
  • The vertical axis represents the value in the sequence, scaled dynamically.
  • Whenever a new number is generated that exceeds the previous maximum, the vertical scale updates automatically.
  • As the number of steps increases, the horizontal scale compresses to keep the entire progression visible.

The Collatz sequence, for every number tested to date, enters the cycle 1 → 4 → 2 → 1. The value 1 acts as an “attractor” toward which all observed sequences converge.

The length of the sequence varies enormously depending on the starting number:

  • Some numbers reach 1 in just a few steps (e.g., 16 → 8 → 4 → 2 → 1, only 5 steps)
  • Others require many steps (the number 97 is the number between 1 and 100 with the longest sequence, reaching 1 in 118 steps)

A particularly interesting case is the number 27: the sequence reaches a peak of 9232 before descending back toward 1. It is noteworthy that 27 is not the only number between 1 and 100 (or even between 1 and 254) whose sequence reaches this maximum value, but it is an excellent example of how the conjecture defies intuition — a seemingly modest number can generate a dramatic vertical excursion.

Despite being formulable in just a few words, the Collatz Conjecture is extraordinarily difficult to prove or refute:

  • Chaotic behavior: the sequence’s evolution does not follow predictable patterns; it appears almost random.
  • Sensitive dependence: small variations in the starting number generate completely different sequences.
  • Lack of obvious algebraic structure: classical methods from linear algebra and number theory prove insufficient.

Even modern computers, which have verified the conjecture for astronomically large numbers (beyond 2602^{60}), have found no counterexample, but also no general proof.

This simulator is useful for:

  • Recursion and iteration: understanding how a simple algorithm generates complex behavior.
  • Critical thinking: observing that sequences reach 1 (empirically) is not the same as proving it rigorously.
  • Dynamic visualization: how the graph’s geometry continuously changes to accommodate the width and height of the sequence.
  • Pattern recognition: seeking regularities, jumps, and structures in the raw data.