# hailstone sequence of perfect squares (collatz conjecture)

The Collatz conjecture states: Take 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 obtain $3n + 1$. Repeat the process indefinitely. The conjecture is that no matter what number you start with, you will always eventually reach 1. The sequence of numbers generated for a particular $n$ is called a hailstone sequence (because of its nature of going up and down then eventually falling like a hailstone).

I was using mathematica with this formula to generate hailstone sequences.

hailstone[n_Integer] :=
Block[{sequence = {}, c = n},
While[c > 1, c = If[EvenQ[c], c/2, 3 c + 1];
AppendTo[sequence, c]];
sequence]


And this to check.

Table[{hailstone[x], x}, {x, Flatten[Table[i^2, {i, 100}]]}]


I was playing around with the Collatz Conjecture and noticed a pattern. Namely all perfect squares that are not of the form $2^j$ (which will simply be divided by two until it reaches $1$) end with the hailstone sequence of $40$, $20$, $10$, $5$, $16$, $8$, $4$, $2$, $1$. I have not proved this rigorously but I have proved it for all perfect squares up to $100^2$ by checking it.

I have been thus far unable to think of a theoretical reason for this. Does anyone know why this might be?

Your conjecture fails for $65^2 = 4225$:

4225
12676 6338 3169
9508 4754 2377
7132 3566 1783
5350 2675
8026 4013
12040 6020 3010 1505
4516 2258 1129
3388 1694 847
2542 1271
3814 1907
5722 2861
8584 4292 2146 1073
3220 1610 805
2416 1208 604 302 151
454 227
682 341
1024 512 256 128 64 32 16 8 4 2 1


This is the smallest counterexample. The next ones are $130^2$ (obviously) and $137^2$.

Furthermore, testing with all odd 6-digit starting points I find that $93.8\%$ of them pass through $40$ on their way to $1$. Of these, $325$ of the $342$ odd 6-digit perfect squares -- that is, $95.0\%$ -- pass through $40$ on their way to $1$. That is only a slightly higher percentage (and it's the other way around for 5-digit numbers), so it doesn't look like starting with a perfect square in general even makes a Collatz sequence more likely to pass through $40$.