Pages

Monday, August 27, 2018

Happy and Sad Numbers

Image result for happy sad numbers
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).[1]
For example: 19 is happy because:
4 lines . Line 1,  19 long right-arrow 1 squared plus 9 squared equals 82 . Line 2,  82 long right-arrow 8 squared plus 2 squared equals 68 . Line 3,  68 long right-arrow 6 squared plus 8 squared equals 100 . Line 4,  100 long right-arrow 1 squared plus 0 squared plus 0 squared equals 1

4 is sad because, following the process above, the pattern is:

4 long right-arrow 16 long right-arrow 37 long right-arrow 58 long right-arrow 89 long right-arrow 145 long right-arrow 42 long right-arrow 20 long right-arrow 4 long right-arrow period period period


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). 

Further Extensions:

  • 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?

No comments:

Post a Comment