Coding Trainer

Happy Number

EasyFast & Slow PointersLC #202

Problem

A happy number repeatedly replaces itself by the sum of squares of its digits until it reaches 1, or loops forever. Return true if n is happy.

Example: 19 → 1²+9²=82 → 8²+2²=68 → ... → 1 → true