Customizable visualization of the Collatz conjecture in JavaScript

GitHub: https://github.com/LelsersLasers/CollatzConjectureVisualization

The visualization follows the Collatz rules while iterating through the sequence. If the current step is twice the value of the next step, a fixed amount of rotation is applied clockwise. Conversely, if the current step is not twice the value of the next step, half of the fixed amount of rotation is applied anticlockwise. The process continues until the value reaches 1, at which point it stops.

The outcome of this algorithm is a collection of threads that resemble an organic entity. The threads appear messy and seemingly randomized, yet they adhere to certain constraints similar to those found in nature. The visualization captures the beauty and complexity of the Collatz sequences in a visually appealing manner.

What is the Collatz conjecture?

The Collatz conjecture, also known as the 3n+1 conjecture or the hailstone sequence, is an unsolved mathematical problem. It was first proposed by German mathematician Lothar Collatz in 1937. The conjecture is defined as follows:

Start with any positive integer n. If n is even, divide it by 2 to get n/2. If n is odd, multiply it by 3 and add 1 to get 3n+1. Repeat the process with the resulting number, and continue iterating in the same way.

The conjecture states that no matter what positive integer you start with, this process will eventually reach the number 1. Once you reach 1, the sequence will enter a loop that repeats indefinitely: 1, 4, 2, 1, 4, 2, 1, and so on.

For example, let's take the starting number 6. The sequence will be: 6, 3, 10, 5, 16, 8, 4, 2, 1. In this case, it took eight steps to reach 1. However, the conjecture claims that for any positive integer, this sequence will eventually reach 1, even though the number of steps it takes may vary.

Despite its simplicity, the Collatz conjecture remains an unsolved problem in mathematics. No counterexamples have been found, meaning that all numbers tested so far eventually reach 1. However, no general proof has been established to show that this is true for all positive integers and the conjecture continues to be an active area of research.

More information


Main resources used

Download

Download NowName your own price

Click download now to get access to the following files:

Web Build.zip 6.6 kB
Source Code.zip 795 kB

Leave a comment

Log in with itch.io to leave a comment.