DEV Community

Discussion on: The Happy Number Problem

Collapse
 
alisabaj profile image
Alisa Bajramovic

I'm dividing n into it's digits (so 19 becomes 1 and 9) and then adding the square of those numbers to the sum.

Collapse
 
haideralipunjabi profile image
Haider Ali Punjabi • Edited

Yeah I got that, but I don't see sum += n*n anywhere

Thread Thread
 
alisabaj profile image
Alisa Bajramovic

The line 'sum += e * e' is what sums the digits

Thread Thread
 
haideralipunjabi profile image
Haider Ali Punjabi

Ahh, I missed the while loop there. Oops