A happy number is defined by the following process:
Starting with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers).
For example: 19 is happy because:
After introducing this to the class some questions you may ask could be:
- What other numbers are happy? Sad?
- Are there any certain numbers that are easy to determine if they are happy/sad? How do you know?
- Would there be an infinite or finite number of happy numbers?
- True or false: If a number is happy (sad), then all numbers of its sequence is happy (sad).
- A happy prime is a number that is both happy and prime. Determine any happy prime numbers. What would be common among all happy primes?
- Change the base (from 10 to 2, or any number) are the numbers still happy/sad, or does it change how the "feeling" of the number?
- Try cubing the digits instead of squaring. Are the numbers still happy/sad, or does the number change "feelings"?
- Computer science challenge: Could you write a code or algorithm that determines if the number is happy or sad?