Skip main navigation

Happy numbers

As with perfect numbers, there is no practical application for happy numbers, however is a useful activity to practise creating number sequences.
© National STEM Learning Centre
As with perfect numbers, there is no practical application for happy numbers. This activity to create sequences of numbers to discover whether a number is a “Happy” number, requires students to follow a simple algorithm, produce unfamiliar sequences and practise squaring numbers.
To find if a number is happy:
  • Replace the number by the sum of the squares of its digits.
  • Repeat the process until either
    • the next number in the sequence is 1, or
    • the sequence loops endlessly in a cycle that does not include 1.
When the sequence gets to 1 then this is the end of the sequence as all subsequent terms in the sequence would be 1. All the numbers in this sequence are happy numbers, otherwise, it is an unhappy number.
Starting with 23 as an example:
\(2^2 = 4\)
\(3^2 = 9\)
\(4 + 9 = 13\)
Hence 13 is the next number in the sequence.
The process is now repeated:
\(1^2 = 1\)
\(3^2 = 9\)
\(1 + 9 = 10\)
Hence 10 is the next number in the sequence.
The process is now repeated:
\(1^2 = 1\)
\(0^2 = 0\)
\(1 + 0 = 1\)
Hence 1 is the next number in the sequence.
The sequence ends at this point since \(1^2 = 1\).
From this we conclude that 23, 13, 10 and 1 are happy numbers.
Not all sequences lead to 1 and a sequence of happy numbers. A sequence of unhappy numbers migrate towards a cyclical loop that includes 4, 16, 37, 58, 89, 145, 42, and 20
Here is an interconnected chain of happy numbers, all leading downwards to one. It does not contain all possible happy numbers.
The chain starts with a selection of numbers each as starting points on many branches, which following the rules as above, all lead to 1 at the end of the chain. The starting numbers at various points in the chain are: 94, 7, 70, 23, 44, 91, 19, 79, 28, 31, 86. Other numbers in the chain are: 49, 32, 97, 13, 82, 68, 130, 10, 100.
When considering numbers between 1 and 100, some of the paths for unhappy numbers can be quite lengthy, for example, 60 takes nine intermediate steps before migrating to the cyclical loop.
The image below illustrates the connections between unhappy numbers.
Starting points for these connections are numerous. All chains lead towards a loop at the centre of the diagram comprising (clockwise): 4, 16, 37, 58, 89, 145, 42, 20.

Problem worksheet

Now complete question 12 from this week’s worksheet
You can read more about happy numbers on the STEM Learning website.
This is the last step of maths content for this course. The next step is a test, which is available if you upgrade and wish to get recognition of your understanding of the topics covered in this course. If you do not want to upgrade, you can skip to step 4.13 to record your professional development.
© National STEM Learning Centre
This article is from the free online

Maths Subject Knowledge: Understanding Numbers

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education