Collatz's Ant

Collatz’s Ant is a visualization for collatz sequences based on Langton’s Ant.

Additionally to what the collatz function is:

\[f(n) = \begin{cases} n/2 & \text{if} \quad n \equiv 0 \quad (\text{mod}\, 2) \\ 3n + 1 & \text{if} \quad n \equiv 1 \quad (\text{mod}\, 2) \\ \end{cases}\]

if $n \equiv 0 \, (\text{mod}\, 2)$ the ant turns 90º clockwise, else the ant turns 90º counter-clockwise. On both accounts, the state of the cell is flipped and the ant moves forward one unit. This is repeated until $n = 1$.

Code and examples.

Some examples

Example of consecutive trajectories from $n = 10^{30}$ to $n = 10^{30} + 20$.

Back