← Back to all posts
##### Why does it only spam 4, 2, 1
MisterMr

I thought it would be fun to make a bot for the 3x+1 theorum but for some reason, no matter what number, it always spams out 4, 2, 1, the end of the sequence. Why is this?

Voters
MisterMr
hotnewtop
QuantumCodes

Did you see veritasium's video? It explains it so well. See if i get 4,
4 = even
4/2 = 2
2 = even
2/2 = 1
1 = odd
3×1+1 = 4
See? It loops.

QuantumCodes

@QuantumCodes this is an unproven thing. But it works for every number

MisterMr

@QuantumCodes Yes I learned about it from the Veritasium video. But I coded it so that it would go like this:
Let's say I have the number... um... 12
It's even so you divide it by 2.
6 is even so you divide it by 2
3 is odd so you multiply by 3 and add 1
10 is even so you get 5
etc etc
and the bot would print all those numbers until it leads to 4, 2, 1

MisterMr

@MisterMr It would print out: 12, 6, 3, 10, 5, etc.

Instead of going straight to 4, 2, 1

QuantumCodes

@MisterMr yes. But the point is it eventually reaches the loop. Thats unproven why it does. So... and there is even a number that rises to millions before going to 4,2,1. Its like you are asking an unproven method to prove it xD

MisterMr

@QuantumCodes I want my code to print every number in the sequence until it goes to 4, 2, 1 (or does something else) but instead it goes straight to 4, 2, 1 and i dont know why.

QuantumCodes

@MisterMr idk wht u even did... try replacing line 19 and 20 with each other

MisterMr

@QuantumCodes That didn't work but thanks for the help!