Start with any whole number N, write N as a multiple of 10 plus a remainder R and produce a new whole number N'. Repeat. What happens?

Whole Number Dynamics I

Stage: 4 and 5

Article by Alan Beardon

Published July 1997,February 2011.

Let us start by discussing the following problem. Take any whole number between 1 and 999 inclusive and add the squares of the digits to get a new number. Try 145 and see what happens.Can you see that, whatever number we start with (between 1 and 999) we always get another number which is less than 1000. Let's use this idea to look at a problem.

In this problem, take any number (less than 1000), add the squares of its digits, and then go on repeating this until a pattern emerges. For example, if we take the number 193, we get the following sequence of numbers :

193 -> 91 -> 82 -> 68 -> 100 -> 1 -> 1 -> 1

Of course, when we reach 1 we will always get 1 thereafter. You were asked to start at 145, and you should have got the sequence

145 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> 89 -> 145

and, of course, the sequence then starts repeating itself. Try some numbers yourself to see what patterns you get.

Numbers, like 193, which start a sequence leading to the number 1 are sometimes called ' happy numbers '.

After trying other starting points you should have been able to guess that, whatever the starting point, eventually you will always reach either 1 (and then you will stay at 1), or the `cycle' given above. One of the aims of these articles is
(1) to try to explain why this is so, and
(2) to consider other situations of this type (i.e. generalisations of it).

The first important step is to show that whichever number we start with (less than 1000) we always get a number less than 1000. Let us see why this is true, and then see why it is important.

We shall consider numbers greater than 1000 in a later article but you may like to try some out now.

Any number less than 1000 has only one, two or three digits, and each of the digit is, of course, at most 9. This means that when we add the squares of the digits, the largest number we can get is 3 x (9 x 9), which is 243, and this is less than 1000. It is worth noting here that although this little argument is very simple, it is (as we said earlier) very important. In mathematics, arguments
can be simple and important, or difficult and unimportant (or, quite often, difficult and important, or simple and unimportant). Being difficult and being important are NOT the same thing !

Now let us see why the argument given above is important. The point is that the eventual behaviour of our sequences of numbers is a very general phenomenon. To illustrate this, suppose that we can now start from any of the numbers 0,1,2, ... ,12, and that now our new rule (corresponding to "add the squares of the digits") is cube the number and take the remainder after throwing away multiples
of 10. This gives the following situation :

0 -> 0

1 -> 1

2 -> 8

3 -> 7

4 -> 4

5 -> 5

6 -> 6

7 -> 3

8 -> 2

9 -> 9

10 -> 0

11 -> 1

12 -> 8

In this case, whatever the starting point, after applying the rule a large number of times, we must end up with one of the six sequences

0 -> 0 -> 0 ...

1 -> 1 -> 1 ...

2 -> 8 -> 2 -> 8 ...

3 -> 7 -> 3 -> 7 ...

6 -> 6 -> 6 ...

9 -> 9 -> 9 ...

Because this rule is different from the original rule, the possible eventual behaviour of the sequences is different ; the important point is that, wherever we start, we eventually get locked into a cyclic situation. The same is true for any rule whatever providing the rule takes us from a FINITE set to itself. It can break down, though, if we consider a set with infinitely many numbers in;
for example, the rule "add 1" applied to the set of positive whole numbers NEVER leads to a cyclic situation.

You should try the following example and see here what the cyclic situations are : the numbers from which you may start are 1,2, ... ,12, and the rule is as follows :

1 -> 2

2 -> 7

3 -> 8

4 -> 6

5 -> 12

6 -> 7

7 -> 1

8 -> 3

9 -> 1

10 -> 3

11 -> 9

12 -> 11

Just to persuade yourself that this always happens, make up an example for yourself (or your friend). To do this, you must

(1) Select a (finite) set of numbers ;
(2) give a rule which takes each of the numbers to another number in the set.
Then repeat the rule with each starting point until a pattern emerges.

Sometimes, all the numbers in the set are in a cycle and sometimes they are not. In all of the examples we have seen so far there is at least one number which is not in one of the eventual cycles. If every number is in a cycle, we say that the rule is a PERMUTATION of the set. Here is an example of a permutation of the letters a , b , c , d , e , f , g, h , i ,j , k , l :

a -> g

b -> j

c -> k

d -> i

e -> a

f -> h

g -> e

h -> b

i -> d

j -> f

k -> c

l -> l

Check that in this case every letter is already in a cycle.

Cut an equilateral triangle out of paper, label the vertices a, b, c (on both sides of the paper), and mark the position of the triangle on a fixed piece of paper on the table. Now find a permutation of a, b, c ; for example, a -> a , b -> c , c -> b , and try to represent this by picking the triangle up and putting it down in the same place but with the vertex c where b was, etc.
Repeat this with other permutations of a, b, c .

Try the same problem for a square. Note that for a square some permutations of the vertices a, b, c, d CANNOT be represented by picking the square up and putting it down again. Why is this ?

Later we shall get back to discussing the "sums of squares of the digits rule" ; the important point to note from the present discussion is that if we have a rule which takes each member of a set to another member of the same set, and if the set is finite, then, if we repeat the rule enough times, we always end up with a cyclic result. This means, for example, that in the case of the triangle,
whatever permutation of a, b, c we choose, we will eventually get the triangle back with its vertices in their original positions.

A final problem : the ideas in this article tell us that if we work out the decimal expansion of a fraction (say of 1/7, or 34/87) we will eventually get a repeating decimal expansion. Can you see why this is ?

The NRICH Project aims to enrich the mathematical experiences of all learners. To support this aim, members of the
NRICH team work in a wide range of capacities, including providing professional development for teachers wishing to
embed rich mathematical tasks into everyday classroom practice. More information on many of our other activities
can be found here.