This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

TheGoldenProof
TheGoldenProof presents ...

2018/4/12

Collatz Calculator

Enter a number and it will spit out ever step it took to get to one and the number of steps it took.

The Collatz Conjecture: If a number (n) is odd multiply by 3 and add 1. If its even, divide by two. You will always reach 1.
Watch this video by numberphile about it:
https://www.youtube.com/watch?v=5mFpVDpKX70

5767 views / 30 in the last 7 days

1 vote | 0 in the last 7 days

Tags: game simulation with-source math calculator collatz

open in greenfoot
Your browser is ignoring the <APPLET> tag.
danpostdanpost

2018/4/12

And 463 takes 128 steps, reaching as high as 9232 before coming down. The number 73 goes up to the same height, taking 115 steps. In fact, the others I had mentions (47, 97 and 107) all reach a maximum of 9232 -- curious.
@danpost the video in the description explains why. Two numbers steps may end up at the same result. for instance if you start at 10 you will get 10 -> 5 -> 16 -> 8 - > 4 -> 2 -> 1, and if you start at 21 you will get 21 -> 64 -> 32 -> 16 -> 8... and so on. Heres a small example: https://occupymath.files.wordpress.com/2017/04/collatz.png?w=700
You'll notice all of those numbers steps contain 107 as the first common number, so everything after 107 is all the same, and with that, you can take and number and, say you wanted to get 50 steps, find the (nSteps - 50)th number up there.
danpostdanpost

2018/4/12

I can understand numbers closer to one being more commonly reached. However, a common high maximum for quite a few relatively small numbers was a bit surprising.
1073741824 has 30 steps. (2^x has x steps)
danpostdanpost

2018/4/12

I guess it makes sense the the ones that take many steps would end up on along similar numbers as the many shorter paths take up most the other numbers.
A new version of this scenario was uploaded on 2018-04-13 13:16:01 UTC Cleaned up code and added what I believe documentation is
A new version of this scenario was uploaded on 2018-04-13 23:48:47 UTC html 5 compatibility since i made the previous changes on an outdates greenfoot version
A new version of this scenario was uploaded on 2018-04-13 23:52:23 UTC what good is documentation of the sourse isnt availible?
A new version of this scenario was uploaded on 2019-01-21 03:16:32 UTC prints steps live.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

nolttr21