This Python script calculates famous 3x+1 Problem and outputs "hailstone numbers". It is also named "3n + 1 conjecture, the Ulam conjecture (after Stanisław Ulam), Kakutani's problem (after Shizuo Kakutani), the Thwaites conjecture (after Sir Bryan Thwaites), Hasse's algorithm (after Helmut Hasse), or the Syracuse problem."(Wikipedia contributors, 2021b).
In case you are not satisfied with this basic explanation, here you can read detailed version
"The Collatz conjecture is a conjecture in mathematics that concerns sequences defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. "(Wikipedia contributors, 2021b)
The sequence of numbers involved is sometimes referred to as the hailstone sequence or hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud), or as wondrous numbers.(Wikipedia contributors, 2021b)
Also you may want to watch this video which made me write this script https://youtu.be/094y1Z2wpJg
References
Wikipedia contributors. (2021b, August 6). Collatz conjecture. Wikipedia. https://en.wikipedia.org/wiki/Collatz_conjecture
- CLONE REPO
git clone https://github.com/snmzcm/CollatzConjecture.git
OR
2.Download as Zip
Execute the script however you want and Enter a positive integer
It works like this:
Enter a positive integer
7
7 -Odd Number
22 -Even Number
11 -Odd Number
34 -Even Number
17 -Odd Number
52 -Even Number
26 -Even Number
13 -Odd Number
40 -Even Number
20 -Even Number
10 -Even Number
5 -Odd Number
16 -Even Number
8 -Even Number
4 -Even Number
2 -Even Number
1 -Odd Number
As you know last three numbers always will be looping according to the problem
Distributed under the GNU License. See LICENSE
for more information.