# Collatz Conjecture - a mathematical mystery ( with Python )

Yes, Nature loves symmetry. Though man discovered mathematics to solve real life and abstract problems, the Nature also obeys some mathematical rules. And sometimes, we all come to a very strange understanding seeing the unsolved mysteries of mathematics. One of that mysteries is the **Collatz Conjecture** or the **3n+1 conjecture**.

This is nothing but a very simple procedure which we can apply to any number. But the fact all the numbers tested on this procedure come to the same output result. Let's say, we have a number N . If it is odd then multiply it by 3 and add 1, meaning **3N+1**. And if it's even then divide it by two or calculate **N/2**. And follow this steps again and again.

let's take any number 19. Odd number so 3*19+1 = 58. It is even so calculate 58/2 = 29. Now odd 3*29+1 = 88 and so on...

88 /2 = 44 44 /2 = 22

22 /2 = 11 3 * 11 +1 = 34

34 /2 = 17 3 * 17 +1 = 52

52 /2 = 26 26 /2 = 13

3 * 13 +1 = 40 40 /2 = 20

20 /2 = 10 10 /2 = 5

3 * 5 +1 = 16 16 /2 = 8

8/2 = 4 4/2 = 2

2/2 = 1 1*3 + 1 = 4

And now it will go through the loop **4 --> 1**. Interestingly, any number you take and do this same procedure will let you come to 4-->1 loop. You can try out with any number and you will get the same result every time. So, why does this happens ? Is it possible that all the numbers in the universe is connected to this procedure and come to same point. So what is the verification that it will converge for any number in the world. Many talents did calculations based on statistics and some did just checks for numbers. **2 ^{68}** numbers had been checked all gave same outcome at last. Also in no mathematical method it is proven that it will be true for any number. Still even now we couldn't find any number which had proved it wrong. So is this a universal truth ? may be. Will the future bring any extraordinary number which will not be obeying this "universal truth" ?

This normal, simple(though deeply interesting and mysterious) procedure is called the Collatz Conjecture. Now I want to say, Python is one of the very modern and famous languages. So I have given the Python code for implementing this Conjecture and try out with various numbers.

```
number = int(input("Enter any number..."))
n = number
while n != 4:
if n%2 == 0:
n = int(n/2)
print(2*n,"/2 = ",n)
else:
n = int(3*n + 1)
print("3 *",int((n-1)/3),"+1 = ",n)
```

That's all for this post. Hope you have liked this post and also found it interesting . Don't forget to try out the code given and and test your own. Ok, Thank you very much. Have a nice day.......

## Comments

## Post a Comment