Showing posts with label four digit numbers. Show all posts
Showing posts with label four digit numbers. Show all posts

Saturday, 29 June 2024

The Number Plate Game


Figure 1

Most number plates in Indonesia display a four digit number as shown in Figure 1 where the number is 1234. A game I like to play as I drive around or am driven around is to try to make a digit equation from these four digits. My rules are that only the four operations of addition, subtraction, multiplication and division are allowed together with exponentiation and brackets. Concatenation of digits is not allowed. Division can be of two types:

  • a digit divided into the next digit e.g. 2 | 4 = 2 which reads 2 divided into 4
  • a digit divided by the next digit e.g. 4 / 2 = 2 which reads 4 divided by 2
For the 1234 in Figure 1, the digit equation is very straightforward:$$ \begin{align}  -1 + 2 &= -3 + 4 \\ 1 &=1 \end{align}$$Theoretically there are \(10^4 = 10000 \) possible numbers ranging from 0000 to 9999. Any numbers with at least two zeroes will form a digit equation. Take 1009 as an example:$$ \begin{align} 1 \times 0 &= 0 \times 9 \\ 0 &=0 \end{align} $$If the digit 1 appears at least twice in the first three digits, then a digit equation is always possible. Take 1814 as an example:$$\begin{align} 1^8 &= 1^4 \\ 1 &=1 \end{align}$$Two consecutive digits are often helpful because they can be collapsed to a 1. Take 6599 as an example:$$\begin{align} 6 - 5 &= 9 \, /  \,9 \\ 1 &=1 \end{align}$$One or more zeroes are also helpful because raising any digit to the zero power produces a 1. Take 9032 as an example:$$\begin{align} 9^0 &= 3-2 \\ 1 &=1 \end{align}$$Brackets also prove very useful as shown in the example of 4894 where we bracket the 8 and 9 and make the 8 negative:$$\begin{align} 4^{-8+9} &= 4 \\ 4^1 &=4 \\ 4&=4  \end{align}$$Of course, forming a digit equation can require a little trickery. Take 3649 as an example:$$\begin{align} 3^{ 6-4}&= 9 \\ 3^2 &=9 \\ 9 &= 9 \end{align}$$Sometimes a digit equation is not possible according to the rules imposed. Take 3637 as an example. I can't see how to make a digit equation out of those four digits.


On the other hand, it's often possible to form digit equations in several different ways. Take our original 1234 as an example where another representations is possible:
$$\begin{align} 1^2 &= -3+4 \\ 1 &=1 \end{align}$$It would be an interesting exercise to work out digit equations for all the numbers between 0000 and 9999 and to make a note of those numbers where an equation is not possible. In fact I've began this process in an Airtable database (link) and it would appear that 0124 is the first four digit number to thwart the creation of a digit equation. I'll keep working on the database and make additions to this post when I discover numbers of interest. It will of course take some time to complete.

See post titled Forming Equations from the Digits of a Number from the 14th of March 2024.

ADDENDUM: July 10th 2024

A variation of this game would be to see if one can get the numbers to total zero. This is very similar to the game already described and every solution to that game becomes a solution to this game because \(a=b \implies a-b=0\). This new, let's call it "zero game", allows for additional numbers plates containing the digit zero to qualify. For example 2470:$$2470 \rightarrow 2 \times 4 \times 7 \times 0 = 0$$Under the old rules this doesn't qualify but here the product of the digits is zero so it does. Another example would be 6772:$$6772 \rightarrow 6 \times  (7 - 7) \times 2 = 0$$Under the old rules, a digit equation could not be formed from these digits but here it can.

Thursday, 17 November 2022

Number + Reversal

I was exploring the sum of numbers and their reversals and discovered something puzzling. Specifically I was looking at how many numbers and their reversals, when added together, produce a prime number. In the range up to 10, there is only one number and that is 1 because 1+1=2. In the range up to 100, there is 1 and 10 because 10 + 1 = 11. In the range up 1000, there are 139 numbers (and thus 13.91%). They are:

1, 10, 100, 116, 118, 140, 142, 146, 158, 166, 170, 172, 178, 182, 188, 190, 196, 215, 217, 229, 239, 241, 245, 257, 265, 269, 271, 277, 281, 287, 295, 299, 314, 316, 328, 338, 340, 344, 356, 364, 368, 370, 376, 380, 386, 394, 398, 413, 415, 427, 437, 439, 443, 455, 463, 467, 469, 475, 479, 485, 493, 497, 499, 512, 514, 526, 536, 538, 542, 554, 562, 566, 568, 574, 578, 584, 592, 596, 598, 611, 613, 625, 635, 637, 641, 653, 661, 665, 667, 673, 677, 683, 691, 695, 697, 710, 712, 724, 734, 736, 740, 752, 760, 764, 766, 772, 776, 782, 790, 794, 796, 811, 823, 833, 835, 839, 851, 863, 865, 871, 875, 881, 889, 893, 895, 910, 922, 932, 934, 938, 950, 962, 964, 970, 974, 980, 988, 992, 994

However, in the range up to 10,000, there are also 139 numbers which means that no new numbers have been added (after 994, the next number is 10012). I checked and rechecked my algorithm but could find no error. It must mean that no four digit number when added to its reverse can produce a prime number. This is in fact true and can be demonstrated by considering a four digit number \(abcd\) and its reverse \(dcba\):$$1000a+100b+10c+d +1000d+100c+10b+a=1001a+110b+110c+1001d$$Each coefficient is divisible by 11 because 1001 = 7 x 11 x 13 and 110 = 2 x 5 x 11. This came as quite a surprise to me. When we check in the range up to 100,000, we find that there are 8428 numbers but again when we extend the range to one million, there are still only 8428. This means that all six digits numbers added to their reversals cannot produce primes. The reason is the same as for the four digit numbers. We find that in the range from 10,000 to 100,000, the numbers that produce primes account for about 9.21% of the total. 

Thus we could summarise: for numbers with \(n\) digits where \(n\)=1, 2, 3, ... the numbers that, when added to their reversals produce primes, total 1, 2, 139, 139, 8428, 8428, ... . I suspect this inability of numbers with an even number of digits (from 4 up) to form primes continues although SageMathCell times out when attempting a range up to ten million. Let's use the three digit numbers to understand what's going on with the numbers that have an odd number of digits. For a number \(abc\) and its reverse \(cba\) we have:$$100a+10b+c+100c+10b+a=101a+20b+101c$$The situation now is quite different because 101 and 20 have no factors in common and the former is in fact a prime number. Thus it is possible for some three digits numbers and their reverses to form prime numbers.

Let's go further and consider the five digit numbers using \(abcde\) and \(edcba\). We have:$$10000a+1000b+100c+10d+e+10000e+1000d+100c+10b+a\\=10001a+1010b+200c+1010d+10001e$$Again the coefficients have no factors in common and so it is possible for prime numbers to arise. The first such number is 10012 which, when added to its reverse 21001, gives the prime number 31013. The final five digit number is 99998 which, when added to its reverse 89999, gives the prime number 189997.

Wednesday, 3 June 2020

Birth Year Magic

Everybody currently living was born in a year that contains four digits. I was born in 1949. My granddaughter was born in 2002. Let's take her year of birth and arrange the digits into ascending and descending order to form two new numbers: 2200 and 0022 (or simply 22). Let's subtract the smaller from the larger. The result is 2178. Let's repeat that process to from 8721 and 1278. Subtraction yields 7443. Continuing this process we get 3996, 6264, 4176 and finally 6174. Why finally? Because subtracting 7641 and 1467 leads us back to 6174! So for 2002, the progression is 2178, 7443, 3996, 6264, 4176, 6174.

Remarkably, all birth years lead to this very same number. Let's take my year of birth: the progression is 1949, 8442, 5994, 5355, 1998, 8082, 8532, 6174. The number 6174 is known as Kaprekar's constant and because it involves four digit numbers with at least two digits different, it's ideally suited to current birth years. You're not going to find someone who was born in 1111 or 2222 who will spoil the trick and so it's an ideal party trick. Everyone has their smartphone near at hand and, if not, one can always be borrowed. Using a calculator app or simply the Chrome browser, the necessary calculations can be quickly and easily carried out.

Figure 1: Google Chrome's Calculator

So Kaprekar's constant connects everybody alive today and in fact everybody born, or still to be born, between the years 1111 and 2222 with those two limits excluded.


There is no other four digit number that returns itself under the operation of subtract digits in ascending order from digits in descending order. There is a nice proof of why this is so on this site that also alerted me to the fact that for three digit numbers there is a constant that is reached as well, namely 495.

Suppose we have four digits \(a,b,c,d\) such that \(9 \geq a>b>c>d \geq 0\). If we can get the same digits (in any order) arising after the subtraction of \(dcba\) from \(abcd\), then we have an unchanging constant. It turns out that that only \(abcd-dcba=bdac\) satisfies and when this is the case \(a=7, b=6, c=4, d=1\). It's the same for the three digit situation \(abc\) and \(cba\) where \(9 \geq a>b>c \geq 0\). Here only \(abc-cba=cab\) satisfies and \(a=9,b=5,c=4\).

A table is also provided showing the situation for numbers of lengths other than 3 and 4. It can be seen that only three and four digit numbers lead to a unique constant. See Figure 1.

Figure 1: source

The site also shows the frequencies of the number of iterations required for four digit numbers to reach 6174. See Figure 2.

Figure 2: source

Here a permalink to some SageMath code that will display, for four digit numbers, the progression in reaching 6174 and count the number of iterations required. Here is another permalink, this time for three digit numbers.

Kaprekar is an interesting mathematician (biography link) and he is also associated with:
  • Kaprekar numbers (Wikipedia link)
  • Harshad numbers (see my blog posts: here and here)
  • Self numbers and Junction numbers (see my blog post here)
Finally we should say a little about the number 6174 and some of its properties. One interesting property is that it can be written as the sum of the first three degrees of 18:$$18^3 + 18^2 + 18^1 = 5832 + 324 + 18 = 6174$$This relationship also means that 6174 is a Harshad number because it is divisible by the sum of its digits (18).