[Community Puzzle] Happy Numbers

[no full code, please]

Seems to be a few bugs in your code, consider the following:

Try printing the visited_nums array and test you’re checking for loops correctly.
Consider checking the _sum is used correctly in all statements.
Consider checking the variable type of _sum and current_num.
Consider checking how many times the while loop is running and why it might be the case.

Hope this helps :slight_smile:

I also used the SET object to store the numbers… if it already exists, i’m in an infinite loop…

You can considere that some numbers drive you to an unHappy number (4, 16, 37, 58, 89… an so on)… if you fall out on these numbers… it’s an unHappy… it’s quicker…

You can also implement a memory of already found numbers during the calculations…