Finds the Total Stopping Time of a Number n in 3x+1.
Seems to be the case that memoization is not the best method even for numbers close to 2^64 and far beyond
There are four commands available after build:
brute- Fast, Single Threaded, supports 64 bit integersbrute2- Fast, Single Threaded, supports literally every integer > 0collatz- Slow, Multithreaded, supports 64 bit integers, but is just too slowbrute3- Fastest, Single Threaded. Essentially brute2 but uses Arbitrary Precision Arithmetic [new]
- No Manual Multitasking takes place
- Is Amazing (in terms of performance)
- Capable of calculating Stopping Time where the number does not shoot off past
18 446 744 073 709 551 615(the upper bound of auint64_tinC++)
- No Manual Multitasking takes place
- Is even more amazing (in terms of performance)
- Capable of calculating stopping time for all positive integers
- Manual Multitasking implemented
- Is extremely slow - Time to calculate stopping time for
10 000is approximately 100s - Memoizes the stopping time for every value less than argument before calculating argument value
- Do not use
Use brute2
- The performance lost to
bruteis negligible - Is unbounded, can literally calculate stopping time of every number (if every number has a stopping time)
- C++ Compiler installed (tested and built with MinGW-w64)
- For windows: MinGW-w64 Download For Windows
- For Linux:
sudo apt-get install gcc-mingw-w64 - For macOS:
sudo port install mingw-w64
- Add MinGW's bin path to your PATH environment variable.
- If you have chosen to use a different C++ compiler, it should work but the build command will differ from those below.
In Terminal:
g++ brute.cpp -o bruteg++ brute2.cpp -o brute2
Depending on Terminal, find out how to run executables.
- In Command Prompt:
brute [number]brute2 [number]
- In powershell:
.\brute [number].\brute2 [number]
- In bash:
./brute [number]./brute2 [number]
The below commands will Find the Total Stopping Time for 392 (which is 27) in the Collatz Conjecture.
brute 392brute2 392
.\brute 392.\brute2 392
./brute 392./brute2 392
- Test Cases:
10^(15)takes an average of0sto calculating stopping time of27510^(30)takes an average of0.005sto calculating stopping time of46710^(100)- A Googol takes an average of0.06sto calculate stopping of1 85510^(500)takens an average of1.83sto calculate stopping time of8 37710^(1000)takes an average of7.54sto calculate stopping time of18 17810^(2000)takes an average of30.6sto calculate stopping time of37 431
Thank you to William Chanrico who's BigInt class was used in building brute2
Thank you to Mordecai Velasco who's bint class was used in building brute3