11 lines
187 B
Text
11 lines
187 B
Text
func happy(n) is cached {
|
|
static seen = Hash()
|
|
|
|
return true if n.is_one
|
|
return false if seen.exists(n)
|
|
|
|
seen{n} = 1
|
|
happy(n.digits.sum { _*_ })
|
|
}
|
|
|
|
say happy.first(8)
|