Kaprekar's routine

From Wikipedia, the free encyclopedia
(Redirected from Kaprekar routine)
Jump to navigation Jump to search

Template:Short description In number theory, Kaprekar’s routine is an iterative algorithm named after its inventor, Indian mathematician D. R. Kaprekar.Template:SfnTemplate:Sfn Each iteration starts with a four-digit random number, sorts the digits into descending and ascending order, and calculates the difference between the two new numbers.

As an example, starting with the number 8991 in base 10:

9981 – 1899 = 8082Script error: No such module "Check for unknown parameters".
8820 – 288 = 8532Script error: No such module "Check for unknown parameters".
8532 – 2358 = 6174Script error: No such module "Check for unknown parameters".
7641 – 1467 = 6174Script error: No such module "Check for unknown parameters".

6174, known as Kaprekar’s constant, is a fixed point of this algorithm. Any four-digit number (in base 10) with at least two distinct digits will reach 6174 within seven iterations.Template:Sfn The algorithm runs on any natural number in any given number base.

Definition and properties

The algorithm is as follows:Template:SfnTemplate:Sfn

  1. Choose any four-digit natural number n in a given number base b. This is the first number of the sequence.
  2. Create a new number α by sorting the digits of n in descending order, and another number β by sorting the digits of n in ascending order. These numbers may have leading zeros, which can be ignored. Subtract αβ to produce the next number of the sequence.
  3. Repeat step 2.

The sequence is called a Kaprekar sequence and the function Kb(n)=αβ is the Kaprekar mapping. Some numbers map to themselves; these are the fixed points of the Kaprekar mapping,[1] and are called Kaprekar’s constants. Zero is a Kaprekar's constant for all bases b, and so is called a trivial Kaprekar’s constant. All other Kaprekar’s constants are nontrivial Kaprekar’s constants.

For example, in base 10, starting with 3524,

K10(3524)=54322345=3087
K10(3087)=8730378=8352
K10(8352)=85322358=6174
K10(6174)=76411467=6174

with 6174 as a Kaprekar’s constant.

All Kaprekar sequences will either reach one of these fixed points or will result in a repeating cycle. Either way, the end result is reached in a fairly small number of steps (within seven iterations or steps).

Note that the numbers α and β have the same digit sum and hence the same remainder modulo b1. Therefore, each number in a Kaprekar sequence of base b numbers (other than possibly the first) is a multiple of b1.

When leading zeroes are retained, only repdigits lead to the trivial Kaprekar’s constant.

In base 4, it can easily be shown that all numbers of the form 3021, 310221, 31102221, 3...111...02...222...1 (where the length of the "1" sequence and the length of the "2" sequence are the same) are fixed points of the Kaprekar mapping.

In base 10, it can easily be shown that all numbers of the form 6174, 631764, 63317664, 6...333...17...666...4 (where the length of the "3" sequence and the length of the "6" sequence are the same) are fixed points of the Kaprekar mapping.

Determination of Kaprekar numbers

In the following, "Kaprekar’s constant Template:Mvar" refers to a number that becomes a positive fixed point Template:Mvar as a result of Kaprekar’s routine.

In 1981, G. D. Prichett, et al. showed that the Kaprekar’s constants are limited to two numbers, 495 (3 digits) and 6174 (4 digits).Template:Sfn They also classified the Kaprekar numbers into four types, but there was some overlap in the classification.

In 2005, Y. Hirata calculated all fixed points up to 31 decimal digits and examined their distribution.Template:Sfn

In 2024, Haruo IwasakiTemplate:Sfn of the Ranzan Mathematics Study Group (headed by Kenichi Iyanaga) showed that in order for a natural number to be a Kaprekar number, it must belong to one of five mutually disjoint sets composed of combinations of the seven numbers 495, 6174, 36, 123456789, 27, 875421 and 09. Iwasaki also showed that this new classification using the five sets includes a corrected classification by Prichett, et al.

As a result, if Template:Mvar is considered as a constant, then the number of decimal Template:Mvar-digit Kaprekar numbers is determined by two types of equations:

(1)  n=3x(x1),  ......... For the sequence of Template:Mvar 3-digit constants 495
(2)  n=4+2x(x0),  ...... Sequence of 4-digit constant 6174 followed by Template:Mvar 2-digit constants 36

or by three types of Diophantine equations:

(3)  n=9x+2y(x1, y0),  ......... Sequence of Template:Mvar 123456789’s and Template:Mvar 36’s
(4)  n=9x+14y(x1, y1),  ...... Sequence of Template:Mvar 123456789’s and Template:Mvar (36 495495 272727)s
(5)  n=6x+2y+9z+2u(x1, y1, z0, u0).  ... Sequence of 124578’s, 09’s, 123456789’s and 36’s

It was found that the number of integer solutions (sets of x~uScript error: No such module "Check for unknown parameters".) of the equations that can be established is the same as the number of solutions that express all of the Template:Mvar-digit Kaprekar numbers.Template:Sfn

The above equations confirm that there are no other Kaprekar’s constants than 495 and 6174. There are no Kaprekar numbers for 1, 2, 5, or 7 digits, since they do not satisfy any of equations (1) through (5). For six-digit numbers, there are two solutions that satisfy equations (1) and (2).[2] Furthermore, it is clear that even-digits with greater than or equal to 8,[3] and with 9 digits,[4] or odd-digits with greater than or equal to 15 digits[5] have multiple solutions. Although 11-digit and 13-digit numbers have only one solution, it forms a loop of five numbers and a loop of two numbers, respectively.[6] Hence, Prichett’s result that the Kaprekar’s constants are limited to 495 (3 digits) and 6174 (4 digits)[7] is verified.

Therefore, the problem of determining all of the Kaprekar’s constants and the number of these was solved.Template:Sfn An example below will explain the Iwasaki’s result.

Example: In the case where decimal digits n = 23Script error: No such module "Check for unknown parameters"., since Template:Mvar is an odd number and is not a multiple of 3, the equations (1) and (2) do not hold, and the only equations that can hold are (3), (4) and (5). And if the operation (denoted by K10Script error: No such module "Check for unknown parameters". ) defined above is applied once to the numbers corresponding to the solutions of these equations, seven Kaprekar numbers can be obtained.

(3) The solution to 23 = 9x + 2yScript error: No such module "Check for unknown parameters". is

(x, y) = (1, 7)Script error: No such module "Check for unknown parameters". :  ...... Sequence of a 123456789 followed by seven 36's
K10 (123456789 36363636363636) = 86433333331976666666532Script error: No such module "Check for unknown parameters"..

(4) The solution to 23 = 9x + 14yScript error: No such module "Check for unknown parameters". is

(x, y) = (1, 1)Script error: No such module "Check for unknown parameters". :  ...... Sequence of 123456789 followed by 36 495495 272727
K10 (123456789 36 495495 272727) = 87765443219997765543222Script error: No such module "Check for unknown parameters"..

(5) The solutions to 23 = 6x + 2y + 9z + 2uScript error: No such module "Check for unknown parameters". are

(x, y, z, u) = (1, 4, 1, 0)Script error: No such module "Check for unknown parameters". :  ...... Sequence of 124578, four 09's and 123456789
K10 (124578 09090909 123456789) = 99998765420987543210001Script error: No such module "Check for unknown parameters".,
(x, y, z, u) = (1, 3, 1, 1)Script error: No such module "Check for unknown parameters". :  ...... Sequence of 124578, three 09's, 123456789 and 36
K10 (124578 090909 123456789 36) = 99987654320987654321001Script error: No such module "Check for unknown parameters".,
(x, y, z, u) = (1, 2, 1, 2)Script error: No such module "Check for unknown parameters". :  ...... Sequence of 124578, two 09's, 123456789 and two 36's
K10 (124578 0909 123456789 3636) = 99876543320987665432101Script error: No such module "Check for unknown parameters".,
(x, y, z, u) = (1, 1, 1, 3)Script error: No such module "Check for unknown parameters". :  ...... Sequence of 124578, 09, 123456789 and three 36's
K10 (124578 09 123456789 363636) = 98765433320987666543211Script error: No such module "Check for unknown parameters"., and
(x, y, z, u) = (2, 1, 1, 0)Script error: No such module "Check for unknown parameters". :  ...... Sequence of two 124578's, 09 and 123456789
K10 (124578124578 09 123456789) = 98776554210988754432211Script error: No such module "Check for unknown parameters"..

Families of Kaprekar’s constants

Script error: No such module "Unsubst".

In case where even base (b = 2k)

It can be shown that all natural numbers

m=(k)b2n+3(i=0n1bi)+(k1)b2n+2+(2k1)bn+1(i=0nbi)+(k1)b(i=0n1bi)+(k)

are fixed points of the Kaprekar mapping in even base b = 2kScript error: No such module "Check for unknown parameters". for all natural numbers Template:Mvar. Template:Math proof

Perfect digital invariants
Template:Mvar Template:Mvar Template:Mvar
1Script error: No such module "Check for unknown parameters". 2Script error: No such module "Check for unknown parameters". 011, 101101, 110111001, 111011110001...Script error: No such module "Check for unknown parameters".
2Script error: No such module "Check for unknown parameters". 4Script error: No such module "Check for unknown parameters". 132, 213312, 221333112, 222133331112...Script error: No such module "Check for unknown parameters".
3Script error: No such module "Check for unknown parameters". 6Script error: No such module "Check for unknown parameters". 253, 325523, 332555223, 333255552223...Script error: No such module "Check for unknown parameters".
4Script error: No such module "Check for unknown parameters". 8Script error: No such module "Check for unknown parameters". 374, 437734, 443777334, 444377773334...Script error: No such module "Check for unknown parameters".
5Script error: No such module "Check for unknown parameters". 10Script error: No such module "Check for unknown parameters". 495, 549945, 554999445, 555499994445...Script error: No such module "Check for unknown parameters".
6Script error: No such module "Check for unknown parameters". 12Script error: No such module "Check for unknown parameters". 5B6, 65BB56, 665BBB556, 6665BBBB5556...Script error: No such module "Check for unknown parameters".
7Script error: No such module "Check for unknown parameters". 14Script error: No such module "Check for unknown parameters". 6D7, 76DD67, 776DDD667, 7776DDDD6667...Script error: No such module "Check for unknown parameters".
8Script error: No such module "Check for unknown parameters". 16Script error: No such module "Check for unknown parameters". 7F8, 87FF78, 887FFF778, 8887FFFF7778...Script error: No such module "Check for unknown parameters".
9Script error: No such module "Check for unknown parameters". 18Script error: No such module "Check for unknown parameters". 8H9, 98HH89, 998HHH889, 9998HHHH8889...Script error: No such module "Check for unknown parameters".

See also

Citations

<templatestyles src="Reflist/styles.css" />

  1. (sequence A099009 in the OEIS)
  2. For six-digit numbers, i.e. Template:Mvar=6, (1) 6=3×2 and (2) 6=4+2×1. From these solutions (1) Template:Mvar=2 and (2) Template:Mvar=1, we obtain 495 495 and 6174 36, respectively. Applying Template:Mvar to these solutions gives us the numbers 549945 and 631764, that are Kaprekar numbers. In fact, Template:Mvar (549945)=549945, and Template:Mvar (631764)=631764.
  3. For even-digits greater than or equal to 8, there are at least two solutions that satisfy equations (2) and (5).
  4. For 9 digits, there are at least two solutions: (1) with Template:Mvar=3, and (3) with (Template:Mvar=1, Template:Mvar=0).
  5. For 15 digits, there are at least two solutions: (1) with Template:Mvar=5, and (3) with (Template:Mvar=1, Template:Mvar=3). For odd digits 17 or greater, there are two solutions that satisfy equations (3) and (5).
  6. The 11-digit number 86420987532 forms a loop with period of 5, and the 13-digit number 8733209876622 forms a loop with period of 2.
  7. For three digits, we get 495 from the solution of (1) with Template:Mvar=1. And for four digits, we get 6174 from the solution of (2) with Template:Mvar=0.

Script error: No such module "Check for unknown parameters".

References

<templatestyles src="Refbegin/styles.css" />

  • Script error: No such module "Citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "Citation/CS1".

External links

Template:Sister project

Template:Classes of natural numbers