Skip to content

Comment on A shower thought turned into a Collatz visualization

Comments

Here is a python script that plots on the Z axis - each number through an entire Collatz cycle until the result of 1, on the X axis - the number of cycles needed to get to 1, on the Y axis - add 1 for odd numbers, subtract 1 for even numbers. https://gist.github.com/bwanaaa/4c77b33311916b230c8b1891bab4...

You can open it in colab to visualize it. You can change the range of integers by modifying line 33 in the function def generate_all_sequences():

Interestingly, it seems there are more odd numbers than even ones in a collatz sequence as all graphs tend to the positive Y axis. All numbers tend to generate 3x as many odd results as even and they all seem to do this at this same rate.

In the first 750 integers, the number 703 reaches as high a collatz result as 250504.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.