James Gray wrote: > Write a program that tells whether a given integer is happy. A happy > number is > found using the following process: Take the sum of the squares of its > digits, > and continue iterating this process until it yields 1, or produces an > infinite > loop. > > For example the number 7: > > 7^2 = 49 > 4^2 + 9^2 = 97 > 9^2 + 7^2 = 130 > 1^2 + 3^2 + 0^2 = 10 > 1^2 + 0^2 = 1 > > If a number is not happy than it is obviously unhappy. Now that you have > this > program, what is the largest happy number you can find? What is the > happiest > number between 1 and 1,000,000. I define the happiest number as the > smallest > number that finds the most other happy numbers with it, i.e. 7 found > four other > numbers (49, 97, 130, and 10) making it a rank 4 in happiness. -Boggles- Okay, I'm feeling stupid here. What MAKES that number be happy? The nearest I can find is that if it's an infinite loop, it isn't happy. If it's not a loop, and resolves to 1 eventually. (It has to resolve to 1, or it's be a loop.) It's happy. Is that right? -- Posted via http://www.ruby-forum.com/.