Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
As part of LitDev's December Challenges, Nonki suggested this Happy Number challenge:
"Calculate happy numbers below 1000."
Read more about Happy Numbers.
Math Man wasted no time in contributing this program:
Math Man's Happy Number Checker (click to try it out!)
Here is what it looks like (just an image):
Now that's a poor, sad number! Bonus points to Math Man for a little humor. =^)
What do you think of the challenge?
- Tall Basic Ed
Comments
Anonymous
December 17, 2012
I thought it was a good challenge because the check for happy numbers was recursive, so we had to be able to contain that recursion while still providing the correct answer to whether that was a happy number or not. The 6 smallest happy numbers are 1, 7, 10, 13, 19, and 23.Anonymous
December 17, 2012
The comment has been removedAnonymous
December 17, 2012
Ed, can you update the program link to smallbasic.com/program It just contains a minor bug fix. Thanks.Anonymous
December 17, 2012
Sorry, when I put the link at the end of the sentence, it thought the question mark was part of the link. Here's the link: smallbasic.com/programAnonymous
December 17, 2012
Math Man, I updated the link. Thanks!Anonymous
December 18, 2012
Ha, Ha, Ha 21122012 - End Of World - is Happy. There is not going to be an end of world. :-)Anonymous
December 18, 2012
@Math Man, You could do this app easier. Every digit is an character and the Text.SubString() for every character in text string: power up twice x * x and add to accumulator. Repeat, until accumulator is >=0 and <9. If accumulator = 1: happy, other: sad. accum = 0 string = ... for every charcter in string accum = accum + (character * character) '''''''''''''''' a character is a single digit, so only it's lenght is 1. end for every string = accum (Small Basic will make a string out of accum) if accum > 9 repeat from the beginning, preserve the string endif if accum < 9 then if accum = then -> HAPPY else ->SAD endif endifAnonymous
December 19, 2012
@ logic thinker Yes. That is actually kind of what I did.Anonymous
December 20, 2012
@Math Man Of course, I didn't mean to teach You. :-) But I just wanted to mention that the problem about determining happy numbers is to repeat an action on a sequence until the length of items making the sequence = 1. Happy Holidays!Anonymous
January 06, 2013
Logic Thinker, You said, "There is not going to be an end of world." Well, if it ended, would you know you were wrong? =^) Thanks to both of you. Good discussion.