A happy number is defined as: start with any positive integer, replace it with the sum of the squares of its digits, and repeat until the number equals or loops endlessly in a cycle that doesn't include .
For example, is happy: , , , .
Write a function that determines if is happy. Use digit extraction (modulo and division) and cycle detection.