Repeated sum-of-squares-of-digits forms a sequence; happy numbers reach 1, others cycle.
Use Floyd cycle detection on the transformation next(n).
Return true iff the fast pointer reaches 1.
Repeated sum-of-squares-of-digits forms a sequence; happy numbers reach 1, others cycle.
Use Floyd cycle detection on the transformation next(n).
Return true iff the fast pointer reaches 1.