hp
toc

Collatz Conjecture

2016-09-03, post № 140

mathematics, programming, Pygame, Python, #3n+1, #three n plus one

The Collatz conjecture states that every positive integer 𝑘 > 𝟢 will — if you iteratively set 𝑘 to 𝑓 (𝑘) — result in 𝟣 (function shown beneath).
The graph beneath shows the path length of numbers from 𝟣 to 𝟣𝟢 𝟢𝟢𝟢. In this range, 𝟨 𝟣𝟩𝟢 is the number with the most steps, 𝟤𝟨𝟣.

f(k)={\begin{cases}\frac{k}{2}&{\text{if }}k\mod 2=0\\3\cdot k+1&{\text{if }}k\mod 2=1\end{cases}}
collatz-conjecture.png
Source code: collatz-conjecture.py
Jonathan Frech's blog; built 2024/04/13 20:55:09 CEST