Is It a Happy Number?
Talk it through out loud with your AI coach.
The problem
- easy
- Pro
Start with a positive whole number and replace it with the sum of the squares of its digits, again and again. If this eventually reaches one, the number is called happy; nineteen is happy, because one plus eighty-one is eighty-two, then sixty-eight, then one hundred, then one. Decide whether a given number is happy, and explain how you know your program will stop.
What a strong answer covers
- What happens to numbers that never reach one.
- A way to notice that the sequence has started repeating.
- An argument that the values stay bounded, so the loop must appear.
- How to split a number into digits, and the memory each method needs.
Common mistake: Looping until the value reaches one with no cycle check, so the program never ends for unhappy numbers.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud