Happy Numbers

Function Kata “Happy Numbers”

Write a function to determine whether a given number is “happy” or not.

A “happy number” is a number where the sum of the squares of its digits “in the long run” is equal to 1. Example:

19 -> 1^2 + 9^2 = 82 -> 8^2 + 2^2 = 68 -> 6^2 + 8^2 = 100 -> 1^2 + 0^2 + 0^2 = 1

Variations #1

Find all “happy numbers” within a range of numbers, e.g. from 10 to 20.