Kaprekar's routine

Last updated

In number theory, Kaprekar's routine is an iterative algorithm named after its inventor, Indian mathematician D. R. Kaprekar. [1] [2] Each iteration starts with a number, sorts the digits into descending and ascending order, and calculates the difference between the two new numbers.

Contents

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

9981 – 1899 = 8082
8820 – 0288 = 8532
8532 – 2358 = 6174
7641 – 1467 = 6174

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. [3] The algorithm runs on any natural number in any given number base.

Definition and properties

The algorithm is as follows: [1] [4]

  1. Choose any natural number in a given number base . This is the first number of the sequence.
  2. Create a new number by sorting the digits of in descending order, and another number by sorting the digits of 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 is the Kaprekar mapping. Some numbers map to themselves; these are the fixed points of the Kaprekar mapping, [5] and are called Kaprekar's constants. Zero is a Kaprekar's constant for all bases , 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,

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 . Therefore, each number in a Kaprekar sequence of base numbers (other than possibly the first) is a multiple of .

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

Families of Kaprekar's constants

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.

In the following, we will refer to the fixed points of the Kaprekar routine not as "Kaprekar constants" but as "Kaprekar numbers defined by Definition 2". In addition, "Kaprekar constant α" refers to the case where all the numbers of that digit become 0 or α due to the Kaprekar routine.

In 2005, Y. Hirata calculated all fixed points up to 31 decimal digits and examined their distribution. [6]

In 1981, Prichett, et al. showed that the Kaprekar constants are limited to two numbers, 495 (3 digits) and 6174 (4 digits). [7] They also classified the Kaprekar numbers into four types, but there was some overlap in the classification.

In 2024, Haruo Iwasaki [8] 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 sets composed of combinations of the seven numbers 495, 6174, 36, 123456789, 27, 124578 and 09, and that this new classification using the five sets includes a corrected classification to that by Prichett, et al.

As a result, the number of decimal n-digit Kaprekar numbers is determined by two types of equations:

  ......... (1) For the sequence of x 3-digit constants 495
  ...... (2) Sequence of 4-digit constant 6174 followed by x 2-digit constants 36

or three types of Diophantine equations:

  ......... (3) Sequence of x 123456789's and y 36's
  ...... (4) Sequence of x 123456789's and y (36 495495 272727)s
  ... (5) Sequence of 124578's, 09's, 123456789's and 36's

It was found that the number of integer solutions (sets of x~u) of the equations that can be established is the same as the number of solutions that express all of the n-digit Kaprekar numbers. [8] In addition, there are no Kaprekar numbers for 5-digit and 7-digit numbers because they do not satisfy the above equations (1)~(5). For six-digit numbers, there are two solutions that satisfy equations (1) and (2). [9] Furthermore, it is clear that even-digits with greater than or equal to 8, [10] and with 9 digit, [11] or odd-digits with greater than or equal to 15 digits [12] 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. [13] Hence, Prichett's result that the "Kaprekar constants" are limited to 495 (3 digits) and 6174 (4 digits) is again verified.

Therefore, the problem of determining all of the Kaprekar numbers defined in Definition 2 and the number of these was solved. [8] An example below will explain the Iwasaki's result.

Example: In the case where decimal digits n = 23, since n is an odd number that is not a multiple of 3, the number of equations that can be solved is limited to the following three, and if the operation (denoted by f ) 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 + 2y is

(x, y) = (1, 7) :  ...... Sequence of a 123456789 followed by seven 36's
f (123456789 363636363636) = 86433333331976666666532.

(4) The solution to 23 = 9x + 14y is

(x, y) = (1, 1) :  ...... Sequence of 123456789 followed by 36 495495 272727
f (123456789 36 495495 272727) = 87765443219997765543222.

(5) The solutions to 23 = 6x + 2y + 9z + 2u are

(x, y, z, u) = (1, 4, 1, 0) :  ...... Sequence of 124578, four 09's and 123456789
f (124578 09090909 123456789) = 99998765420987543210001,
(x, y, z, u) = (1, 3, 1, 1) :  ...... Sequence of 124578, three 09's, 123456789 and 36
f (124578 090909 123456789 36) = 99987654320987654321001,
(x, y, z, u) = (1, 2, 1, 2) :  ...... Sequence of 124578, two 09's, 123456789 and two 36's
f (124578 0909 123456789 3636) = 99876543320987665432101,
(x, y, z, u) = (1, 1, 1, 3) :  ...... Sequence of 124578, 09, 123456789 and three 36's
f (124578 09 123456789 363636) = 98765433320987666543211, and
(x, y, z, u) = (2, 1, 1, 0) :  ...... Sequence of two 124578's, 09 and 123456789
f (124578124578 09 123456789) = 98776554210988754432211.

b = 2k

It can be shown that all natural numbers

are fixed points of the Kaprekar mapping in even base b = 2k for all natural numbers n.

Proof

Perfect digital invariants
kbm
1 2 011, 101101, 110111001, 111011110001...
2 4 132, 213312, 221333112, 222133331112...
3 6 253, 325523, 332555223, 333255552223...
4 8 374, 437734, 443777334, 444377773334...
5 10 495, 549945, 554999445, 555499994445...
6 12 5B6, 65BB56, 665BBB556, 6665BBBB5556...
7146D7, 76DD67, 776DDD667, 7776DDDD6667...
8 16 7F8, 87FF78, 887FFF778, 8887FFeFF7778...
9188H9, 98HH89, 998HHH889, 9998HHHH8889...

See also

Citations

  1. 1 2 Kaprekar 1955.
  2. Kaprekar 1980.
  3. Hanover 2017, p. 1, Overview.
  4. Hanover 2017, p. 3, Methodology.
  5. (sequence A099009 in the OEIS )
  6. Hirata 2005.
  7. Prichett 1981.
  8. 1 2 3 Iwasaki 2024.
  9. For six-digit numbers, i.e. n=6, (1) 6=3×2 and (2) 6=4+2×1. From these solutions (1) x=2 and (2) x=1, we obtain 495 495 and 6174 36, respectively. Applying f to these solutions gives us the numbers 549945 and 631764, that are Kaprekar numbers. In fact, f (549945)=549945, and f (631764)=631764.
  10. For even-digits greater than or equal to 8, there are at least two solutions that satisfy equations (2) and (5).
  11. For 9 digits, there are at least two solutions: (1) with x=3, and (3) with (x=1, y=0).
  12. For 15 digits, there are at least two solutions: (1) with x=5, and (3) with (x=1, y=3). For odd digits 17 or greater, there are two solutions that satisfy equations (3) and (5).
  13. 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.

Related Research Articles

<span class="mw-page-title-main">Fibonacci sequence</span> Numbers obtained by adding the two previous ones

In mathematics, the Fibonacci sequence is a sequence in which each element is the sum of the two elements that precede it. Numbers that are part of the Fibonacci sequence are known as Fibonacci numbers, commonly denoted Fn. Many writers begin the sequence with 0 and 1, although some authors start it from 1 and 1 and some from 1 and 2. Starting from 0 and 1, the sequence begins

<span class="mw-page-title-main">Natural logarithm</span> Logarithm to the base of the mathematical constant e

The natural logarithm of a number is its logarithm to the base of the mathematical constant e, which is an irrational and transcendental number approximately equal to 2.718281828459. The natural logarithm of x is generally written as ln x, logex, or sometimes, if the base e is implicit, simply log x. Parentheses are sometimes added for clarity, giving ln(x), loge(x), or log(x). This is done particularly when the argument to the logarithm is not a single symbol, so as to prevent ambiguity.

In mathematics, the Euler numbers are a sequence En of integers defined by the Taylor series expansion


In mathematics, a generating function is a representation of an infinite sequence of numbers as the coefficients of a formal power series. Generating functions are often expressed in closed form, by some expression involving operations on the formal series.

<span class="mw-page-title-main">Square number</span> Product of an integer with itself

In mathematics, a square number or perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 9 is a square number, since it equals 32 and can be written as 3 × 3.

In recreational mathematics, a repunit is a number like 11, 111, or 1111 that contains only the digit 1 — a more specific type of repdigit. The term stands for "repeated unit" and was coined in 1966 by Albert H. Beiler in his book Recreations in the Theory of Numbers.

<span class="mw-page-title-main">Bernoulli polynomials</span> Polynomial sequence

In mathematics, the Bernoulli polynomials, named after Jacob Bernoulli, combine the Bernoulli numbers and binomial coefficients. They are used for series expansion of functions, and with the Euler–MacLaurin formula.

In mathematics, a natural number in a given number base is a -Kaprekar number if the representation of its square in that base can be split into two parts, where the second part has digits, that add up to the original number. For example, in base 10, 45 is a 2-Kaprekar number, because 45² = 2025, and 20 + 25 = 45. The numbers are named after D. R. Kaprekar.

In number theory, a formula for primes is a formula generating the prime numbers, exactly and without exception. Formulas for calculating primes do exist; however, they are computationally very slow. A number of constraints are known, showing what such a "formula" can and cannot be.

In mathematics, the Champernowne constantC10 is a transcendental real constant whose decimal expansion has important properties. It is named after economist and mathematician D. G. Champernowne, who published it as an undergraduate in 1933. The number is defined by concatenating the base-10 representations of the positive integers:

A divisibility rule is a shorthand and useful way of determining whether a given integer is divisible by a fixed divisor without performing the division, usually by examining its digits. Although there are divisibility tests for numbers in any radix, or base, and they are all different, this article presents rules and examples only for decimal, or base 10, numbers. Martin Gardner explained and popularized these rules in his September 1962 "Mathematical Games" column in Scientific American.

<span class="mw-page-title-main">Central binomial coefficient</span> Sequence of numbers ((2n) choose (n))

In mathematics the nth central binomial coefficient is the particular binomial coefficient

In mathematics, Apéry's constant is the infinite sum of the reciprocals of the positive integers, cubed. That is, it is defined as the number

In number theory, a Dudeney number in a given number base is a natural number equal to the perfect cube of another natural number such that the digit sum of the first natural number is equal to the second. The name derives from Henry Dudeney, who noted the existence of these numbers in one of his puzzles, Root Extraction, where a professor in retirement at Colney Hatch postulates this as a general method for root extraction.

In number theory, a narcissistic number in a given number base is a number that is the sum of its own digits each raised to the power of the number of digits.

Approximations of <span class="texhtml mvar" style="font-style:italic;">π</span> Varying methods used to calculate pi

Approximations for the mathematical constant pi in the history of mathematics reached an accuracy within 0.04% of the true value before the beginning of the Common Era. In Chinese mathematics, this was improved to approximations correct to what corresponds to about seven decimal digits by the 5th century.

A sum-product number in a given number base is a natural number that is equal to the product of the sum of its digits and the product of its digits.

<span class="mw-page-title-main">Natural logarithm of 2</span> Mathematical constant

In mathematics, the natural logarithm of 2 is the unique real number argument such that the exponential function equals two. It appears regularly in various formulas and is also given by the alternating harmonic series. The decimal value of the natural logarithm of 2 truncated at 30 decimal places is given by:

<span class="mw-page-title-main">Moser–de Bruijn sequence</span> Number, sum of distinct powers of 4

In number theory, the Moser–de Bruijn sequence is an integer sequence named after Leo Moser and Nicolaas Govert de Bruijn, consisting of the sums of distinct powers of 4. Equivalently, they are the numbers whose binary representations are nonzero only in even positions.

References

^