Happy number in my last blog is pretty straight forward. But there are a lot interesting things from the example. I'm now starting to search the algorithms that
1. find the list of all happy numbers in a given range. For example, give me a list of all happy number between 1 000 000 and 2 000 000.
2. find any n happy numbers in a given range. For example, give me any 100 happy numbers between 1 000 000 and 2 000 000. This should be slightly different than the first problem, because it is easy to see that 1 111 111 is a happy number with the knowledge that 7 is a happy number. So, the algorithms to find any 100 happy numbers might be much more efficient than finding the first consecutive 100 happy numbers.
I would also like to know the behavior of happy number algorithms when the search is done in several threads. Would it be faster ? How much faster ? What kind of multi threading algorithms will solve the problem better ?
Another interesting question would be how to store the happy or sad number discovered so far. The lst in my previous blog for example stores the numbers being visited in the calculation. Once the decision whether a number is happy or sad, the happiness of the visited numbers (that is, the lst) can be determined. For example, from our calculation of 7, we can deduce that 97, 130, and 10 are happy numbers. Similarly, from our calculation of 4, we deduce that 16, 37, 58, 89, 145, 42, and 20 are sad. What about the store itself, should it be a bitset so that I can store a lot of number ?
I'm pretty sure that there have been a lot attempts to answer the same questions, and yes, I tell myself, let's start the journey of research ..., the research for happiness.