```
public class Solution {
public bool IsHappy(int n) {
List<int> list = new List<int>();
while(n != 1)
{
n = getSum(n);
if (list.Contains(n))
{
return false;
}
else
{
list.Add(n);
}
}
return true;
}
private static int getSum(int n)
{
int sum = 0;
while (n != 0)
{
sum += (n % 10) * (n % 10);
n /= 10;
}
return sum;
}
}
```