The demonstration of the 3xplus1 recursive function which always concverges no the same numbers. The system is defined by the following.
f(x) = {3x+1} if f(x) is odd
f(x) = (f(x)/2) if f(x) is even.
Put another way,
Rules:
If f($x$) is odd, f(f($x$)) = 3(f($x$) + 1) + 1,
else, f($x$) = f($x$) /2.
Repeat until f($x$) = 4, then f($x$) = 2 then f($x$) = 1 (stop!)
For seemingly any seednumber
, the algorithm haults on the same last three numbers; [8, 4, 2, STOP]. Below we arbitrality start the algorithm with the
For a seed number of 10,
python3 threeXPlusOne.py -n 10
[+] Seed Number: 10
0, 10 even
1, 5.0 odd
2, 16.0 even
3, 8.0 even
4, 4.0 even
5, 2.0 even
[+] Completed at 1.0, MaxValue = 16.0
For a seed number of 30,
python3 threeXPlusOne.py -n 30
python3 threeXPlusOne.py -n 30
[+] Seed Number: 30
0, 30 even
1, 15.0 odd
2, 46.0 even
3, 23.0 odd
4, 70.0 even
5, 35.0 odd
6, 106.0 even
7, 53.0 odd
8, 160.0 even
9, 80.0 even
10, 40.0 even
11, 20.0 even
12, 10.0 even
13, 5.0 odd
14, 16.0 even
15, 8.0 even
16, 4.0 even
17, 2.0 even
[+] Completed at 1.0, MaxValue = 160.0
Note that, again, the last numbers, {8,4,2, STOP} are the ending elements of the sequence.
We create the sequences of seed values from 1 to 30 and plot each below.
In accordance with according to Collatz Conjecture, the plotted results from the first thirty seeds, convege to values [4, 2, 1]. Sequences from very large numbers have also been tested by these same rules and none to date have been found to terminate on other values than [4, 2, 1].
Make histrory by finding a logical reason to explain why the equation $f(x) = 3x+1$ gives these distiguishing terminating sequences, while other (similar) equations have no such convergencing sequences.
-
Wikipedia: Collatz Conjecture
-
The Simplest Math Problem No One Can Solve - Collatz Conjecture
-
UNCRACKABLE? The Collatz Conjecture - Numberphile