Simple tool to brute force 3x+1 for a second loop. Only takes positive numbers.
It detects a new loop by checking if the smallest number it has encountered appears again. It is my theory that if there is another loop it will probably be the smallest number it has encoutnered.
This doesn't detect if there is a run away event where a number shoots into infinity (Or the max of a U128 int) but if you ever find an area where it loops into infinity or crashes then you can run that smaller section of numbers if -d
which will output every operation, use this to find what number it is and what path is taken.
USAGE:
rust-3xp1.exe [OPTIONS]
OPTIONS:
-c, --count <COUNT> Number of times to try [default: 50000]
-d, --double-verbose Weather to output current number every step of 3x+1
-h, --help Print help information
-s, --start <START> Number to start at [default: 195147905179352825856]
-v, --verbose Weather to output current number each time
-V, --version Print version information
check out this video by Veritasium
This hasn't left my brain since I saw the video, I wanted to mess around with a tool to brute force for a new loop.
The base of this entire code is that the smallest number is where a new loop will be found. Based on the 4 known loops where the number that it loops around to is also the closest number to 0 in that cycle I do belive so.
There is no real way of knowing without checking or finding a number that leaves this code running forever at which point you will have to investigate fruther with -d
.