Share your repls and programming experiences

← Back to all posts
The Collatz Conjecture
LizFoster (640)

I made this after learning about it from one of my favorite English YouTubers.

The Collatz Conjecture is a fairly simple idea. You start with any positive integer, and go from there. If the integer is even, you divide it by two, and if it is odd, you multiply it by three and add one. You keep iterating it over and over like this, and it levels out. I've made it print out the average, highest, and lowest values at the end

Please Enjoy! Any feedback would be greatly appreciated.
(´,,•ω•,,)♡

PS good morning -.-

Comments
hotnewtop
mwilki7 (1132)

ive never heard of this before
but it sounds like it can be fractally if mapped to x,y plane

LizFoster (640)

@mwilki7 Oh, wow~! That looks very pretty! Good work!

AmazingMech2418 (1046)

The conjecture is actually that it will eventually reach 1 after enough iterations. However, great job! Maybe, next you could try to prove the conjecture (at least experimentally using a program to test every number possible since nobody has actually proven it mathematically before and it is an open problem in mathematics)!

LizFoster (640)

@AmazingMech2418 Oh, so I should do something mathematical that no one has yet to do?! Sounds easy!wwwwwwww

AmazingMech2418 (1046)

@LizFoster Well, at least an experimental "proof". Really just testing as many numbers as possible.

LizFoster (640)

@AmazingMech2418 Actually, I can think of a method already!!!

AmazingMech2418 (1046)

@LizFoster To prove the Collatz Conjecture?

AmazingMech2418 (1046)

@LizFoster Maybe next you should try the Riemann Hypothesis. LOL! (though, actually, you could) How would you prove the Collatz Conjecture which nobody has proven for decades?

LizFoster (640)

@AmazingMech2418 It's difficult to explain very well.. You go through each integer value, and as long as the user still wants to keep going, it keeps testing the next highest integer, and then says how many iterations it took to get to 1. for 1 it is 0, for 2 it is 1, etcetera.

AmazingMech2418 (1046)

@LizFoster That should work as an experimental proof.

LizFoster (640)

@AmazingMech2418 Yay! I was honestly a little bit worried you'd think it was dumb..

AmazingMech2418 (1046)

@LizFoster Nope! That's pretty much what I was thinking too. However, at first, I did think you were talking about a mathematical proof...

LizFoster (640)

@AmazingMech2418 No, that would be incredible. Are you referring to a formula that would find the number of required iterations?

AmazingMech2418 (1046)

@LizFoster No. I mean a proof that all numbers will reach 1 eventually.

LizFoster (640)

@AmazingMech2418 Ah, okay. I'm trying to think of a way that you could do so, but I must say, it's certainly proving to be difficult!wwwwwwww

Sorry to get your hopes up..

AmazingMech2418 (1046)

@LizFoster This is a graph of numbers in the Collatz Conjecture (scroll to the right to see more once on the website): https://collatzgraph.amazingmech2418.repl.co/ Notice that there are more flat lines towards the right of it. That means that more numbers have the same values there. For some reason, I'm thinking it might have something to do with the Riemann Zeta Function, but I'm not exactly sure why...

AmazingMech2418 (1046)

@LizFoster The graph might be down. I'm just running a few more iterations to get more numbers in the graph.

AmazingMech2418 (1046)

@LizFoster Each vertical line represents a number inputted into the Collatz Conjecture with a height of the number of iterations.

AmazingMech2418 (1046)

@LizFoster This is what I got if you don't want to actually go to the website.

You have to open it in a new tab since it is very wide. Or just go to this link: https://storage.googleapis.com/replit/images/1586883989290_d299f19f84ff2ff6ec299132a6d09833.png (and zoom in of course)

AmazingMech2418 (1046)

@LizFoster If you try to open the website and it is down, please let me know. I'm not sure how the prompt for starting the server or continuing with more iterations will work if it has to wake up the repl. It being down means that you don't see anything on the screen.

LizFoster (640)

@AmazingMech2418 No, it is fine. My devices are just suddenly lagging quite a bit for some reason..

Interesting. Yeah, it's possible that it does have something to do with that, but I'd be interested to see how one would convert it over..

LizFoster (640)

@AmazingMech2418 *that being the Riemann Zeta Function

AmazingMech2418 (1046)

@LizFoster Do you have any other ideas about why the graph may have the shape it has?

LizFoster (640)

@AmazingMech2418 None. It looks suspiciously like a logarithm though, so I'll see if I can find any ties!

AmazingMech2418 (1046)

@LizFoster Yeah. I thought Riemann Zeta because of the similarities later on between different values. However, it might be a mixture between the two, logarithms for the basic shape and zeta for the variation.

LizFoster (640)

@AmazingMech2418 Hmmm.. This is so exciting!

AmazingMech2418 (1046)

@LizFoster Yeah, it is! Who knows? Maybe we could solve the Collatz Conjecture!

LizFoster (640)

@AmazingMech2418 That would be absolutely incredible! We should take this somewhere easier to communicate. Multiplayer repl, or Google Hangout maybe?

LizFoster (640)

@AmazingMech2418 I don't want anyone stealing this wwwwwwww

AmazingMech2418 (1046)

@LizFoster Probably a multiplayer repl would be easiest.

AmazingMech2418 (1046)

@LizFoster Should I start the repl or should you?

LizFoster (640)

@AmazingMech2418 Yeah, you're right. I'll invite you to one

LizFoster (640)

Keep in mind that the higher the value you enter for the second one, the longer it'll take to finish, so please do something reasonable if time is of the essence.