Happy Number
Input: 19
Output: true12 + 92 = 82
82 + 22 = 68
62 + 82 = 100
12 + 02 + 02 = 1Basic Idea:
class Solution { public: bool isHappy(int n) { while (n != 1 && n != 4) { int t = 0; while (n > 0) { t += pow(n % 10, 2); n /= 10; } n = t; cout << n << endl; } return n == 1; } };