[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 ![]()
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ā¦