Collatz Conjecture

8 posts in this topic

layer 2

so literally just tonight, i realized and identified the fact that ive always been amazed at math theories, and unsolved math problems.. i always was, but just never really knew it, but at the same time i did

well since i havent been using autoit a lot latley or any programming language, just because, it took me a while to find out that i needed $check inside the loop and that the script wasnt functioning like it should because i did $snum/3+1 when it was supposed to be $snum*3+1.. that mistake was because i was tired :"> (check code below to know what im talking about)

so basically, the Collatz Conjecture (theory;guess) is a theory thought up Lothar Collatz, stating that if you multiply every odd number by three and add one to it, and divide ever even number by two, sooner or later (it may take a long while, but sooner or later) you will get to the "never ending" 4, 2, 1 ... so this code just lets you input a starting number, and a messagebox that you have to click ok to keep the loop going will pop up after every calculation..

oh, and one more thing ! try starting out w/ a number like 20 or something, and in about 5 numbers, you will get the 4, 2, 1 .. if you find a number that doesnt produce 4, 2, 1 when it gets to that point (like when you get down the the single digits, who knows how long that will take with some numbers, id imagine well over a hundred, give or take a few hundred, well, dont tell anyone except someone who will pay you for the number, because you just solved the Collatz conjecture

now that im reading wikipedia, they have pseudocode as well.. but i like to see what the code is doing so i added messageboxes (may take forever if you enter a BIG number )

i would say enjoy, but i know not everyone likes math, well i dont, i like the theory, but not the stuff they teach in school (although some of it from school i like and actually relaxes me and takes some stress away )

edit: updated code

edit2: added two lines of code under the inputboxes to check for "" and if so, exit

Share this post

Link to post

Share on other sites

nikink 1

i just dont like ConsoleWrite so i used GUI, and added a few other little things

edit: oh yea, and using a bigger number doesnt necessarily take longer, try using 27, that takes a lot longer than a number like 1000

this is why i think there is no one number (whole positive number) that will ever NOT yield 4, 2, 1 with this theory, because it all breaks down to odd and evens, and sometimes the size of the number

edit2: well i guess using a number like 1000000000000001 or whatever, is just too big for, well im not sure, but everything goes bleh .. oh well, im sure on paper, it would all work out

I think this is why a graph of the iterations would be useful. If you could look at the graph and identify a pattern to the number of iterations required per number, it might help lead to yet more interesting number patterns that might maybe perhaps lead to insight?

Or it might just look cool! B-)

I've been able to modify the script posted by Smoke_N to display the number of iterations each number requires to reach 1 but I have no idea if or how AutoIt could graph it. Maybe write to Excel COM would be the simplest? Then let Excel do all the work.

Looking at the iterations it doesn't look random. Not all over the place random anyway. There seems to be certain numbers of iterations that occur frequently, often in runs...

I dunno. More obvious with graphs anyway ... B-)

Share this post

Link to post

Share on other sites

layer 2

I think this is why a graph of the iterations would be useful. If you could look at the graph and identify a pattern to the number of iterations required per number, it might help lead to yet more interesting number patterns that might maybe perhaps lead to insight?

Or it might just look cool! B-)

I've been able to modify the script posted by Smoke_N to display the number of iterations each number requires to reach 1 but I have no idea if or how AutoIt could graph it. Maybe write to Excel COM would be the simplest? Then let Excel do all the work.

Looking at the iterations it doesn't look random. Not all over the place random anyway. There seems to be certain numbers of iterations that occur frequently, often in runs...

I dunno. More obvious with graphs anyway ... B-)

yea i see what you're saying, i just don't know how to make graphs w/ autoit :">