Happy Number — Solution & Editorial
Iterate the digit-square-sum map with a seen-set (or Floyd cycle detection); values quickly drop below 1000, so it terminates fast.
Complexity: O(iterations) — effectively constant
Iterate the digit-square-sum map with a seen-set (or Floyd cycle detection); values quickly drop below 1000, so it terminates fast.
Complexity: O(iterations) — effectively constant