Take a number, find the sum of the squares of all its digits, then do the same to all the digits of the sum, and keep on that process until you either end up with 1 or an infinite loop. In the first case, the number is happy. FMI, http://en.wikipedia.org/wiki/Happy_number and http://mathworld.wolfram.com/HappyNumber.html Best Wishes