```
func isHappy(n int) bool {
hash := make(map[int]bool)
for {
res := 0
for n > 0 {
num := n % 10
res = res + num*num
n = n / 10
}
if res == 1 {
return true
}
_, ok := hash[res]
if ok {
return false
}
hash[res] = true
n = res
}
}
```