16 lines
686 B
Markdown
16 lines
686 B
Markdown
# Collatz conjecture solver
|
|
### (x%2==0) ? x/=2 : x=x*3+1;
|
|
|
|
### You probably want the GMP version for arbitrarily big numbers. Get it from the [GMP branch](https://git.sdf.org/ilikecats/collatz/src/branch/gmp).
|
|
|
|
Program to solver the [Collatz conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture).
|
|
|
|
Algorithm:
|
|
- Start with number.
|
|
- If number is even, divide by two.
|
|
- If number is odd, multiply by three and add one.
|
|
- Repeat.
|
|
|
|
To figure out if it will repeat, save all the previous numbers, and check if the current number is one of those.
|
|
If it is, that means it will repeat, and you have disproved the Collatz conjecture. So far, though, nobody has disproven it up to 2^68.
|