Javascript web page
log in

Advanced search

Message boards : Web site : Javascript web page

Author Message
Profile S@NL - FilmFreak
Send message
Joined: 18 Jul 09
Posts: 6
Credit: 67,068,732
RAC: 0
Message 14246 - Posted: 14 Jun 2012, 13:11:55 UTC

A while ago I have created a javascript web page for the Collatz conjecture. You can enter a number and you'll get the collatz sequence for that number. I set it to end the line when you have odd integer. Would you like to implement this in your web site? And do you have any suggestions or corrections? English is not my native tongue. You can find it here and the javascript file is here.
____________

Profile Slicker
Volunteer moderator
Project administrator
Project developer
Project tester
Project scientist
Avatar
Send message
Joined: 11 Jun 09
Posts: 2525
Credit: 740,580,099
RAC: 1
Message 14254 - Posted: 14 Jun 2012, 17:56:48 UTC - in response to Message 14246.

A while ago I have created a javascript web page for the Collatz conjecture. You can enter a number and you'll get the collatz sequence for that number. I set it to end the line when you have odd integer. Would you like to implement this in your web site? And do you have any suggestions or corrections? English is not my native tongue. You can find it here and the javascript file is here.


I visited the site and tried entering a number from a recent workunit I completed: 2375754252142505466795
The site gave me an error stating the number was too large. So, you may want to figure out what the max value your page supports and put that in the instructions (e.g. between 2 and XXXXXXX)

I've seend it done in Java using the big integer class to support really large numbers, but never in javascript. Pretty cool.

Profile S@NL - FilmFreak
Send message
Joined: 18 Jul 09
Posts: 6
Credit: 67,068,732
RAC: 0
Message 14256 - Posted: 14 Jun 2012, 18:10:01 UTC

The max is 16 digits. I'll see if I can get 2 of those to act as one so it'll be 32 digits.

Profile S@NL - FilmFreak
Send message
Joined: 18 Jul 09
Posts: 6
Credit: 67,068,732
RAC: 0
Message 14280 - Posted: 19 Jun 2012, 16:40:32 UTC - in response to Message 14256.

And I did! 32 digits is still too large but 31 is not. It takes 1679 steps for 2375754252142505466795 to reach 1.

Profile S@NL - FilmFreak
Send message
Joined: 18 Jul 09
Posts: 6
Credit: 67,068,732
RAC: 0
Message 15918 - Posted: 13 Jan 2013, 14:50:07 UTC

Now I have constructed a script without a max. I've limited the starting number to 50 digits though, so it won't take hours/days/years, but the numbers in the sequence don't matter.

Theadalus
Send message
Joined: 7 Oct 10
Posts: 2
Credit: 2,270,456
RAC: 0
Message 16040 - Posted: 22 Feb 2013, 18:31:11 UTC - in response to Message 15918.

Script seems to crash (or infinite loop) on empty input(box)... amazing people sometimes forget the most simple things. ;-)


Post to thread

Message boards : Web site : Javascript web page


Main page · Your account · Message boards


Copyright © 2018 Jon Sonntag; All rights reserved.