Kaprekar's routine

Last updated

In number theory, Kaprekar's routine is an iterative algorithm named after its inventor, Indian mathematician D. R. Kaprekar. 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. [1] The algorithm runs on any natural number in any given number base.

Definition and properties

The algorithm is as follows: [2]

  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, [3] 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.

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.

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. Hanover 2017, p. 1, Overview.
  2. Hanover 2017, p. 3, Methodology.
  3. (sequence A099009 in the OEIS )

Related Research Articles

<span class="mw-page-title-main">Binomial coefficient</span> Number of subsets of a given size

In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers nk ≥ 0 and is written It is the coefficient of the xk term in the polynomial expansion of the binomial power (1 + x)n; this coefficient can be computed by the multiplicative formula

<span class="mw-page-title-main">Exponential distribution</span> Probability distribution

In probability theory and statistics, the exponential distribution or negative exponential distribution is the probability distribution of the distance between events in a Poisson point process, i.e., a process in which events occur continuously and independently at a constant average rate; the distance parameter could be any meaningful mono-dimensional measure of the process, such as time between production errors, or length along a roll of fabric in the weaving manufacturing process. It is a particular case of the gamma distribution. It is the continuous analogue of the geometric distribution, and it has the key property of being memoryless. In addition to being used for the analysis of Poisson point processes it is found in various other contexts.

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

In mathematics, a formal series is an infinite sum that is considered independently from any notion of convergence, and can be manipulated with the usual algebraic operations on series.

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.

In mathematics, the Hermite polynomials are a classical orthogonal polynomial sequence.

<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 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.

<span class="mw-page-title-main">Double factorial</span> Mathematical function

In mathematics, the double factorial of a number n, denoted by n, is the product of all the positive integers up to n that have the same parity as n. That is,

<span class="mw-page-title-main">D. R. Kaprekar</span> Indian recreational mathematician (1905–1986)

Dattatreya Ramchandra Kaprekar was an Indian recreational mathematician who described several classes of natural numbers including the Kaprekar, harshad and self numbers and discovered the Kaprekar's constant, named after him. Despite having no formal postgraduate training and working as a schoolteacher, he published extensively and became well known in recreational mathematics circles.

<span class="mw-page-title-main">Dirichlet beta function</span>

In mathematics, the Dirichlet beta function is a special function, closely related to the Riemann zeta function. It is a particular Dirichlet L-function, the L-function for the alternating character of period four.

The Engel expansion of a positive real number x is the unique non-decreasing sequence of positive integers such that

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.

In mathematics, the Bessel polynomials are an orthogonal sequence of polynomials. There are a number of different but closely related definitions. The definition favored by mathematicians is given by the series

In number theory and mathematical logic, a Meertens number in a given number base is a natural number that is its own Gödel number. It was named after Lambert Meertens by Richard S. Bird as a present during the celebration of his 25 years at the CWI, Amsterdam.

<span class="mw-page-title-main">Perrin number</span> Number sequence 3,0,2,3,2,5,5,7,10,...

In mathematics, the Perrin numbers are a doubly infinite constant-recursive integer sequence with characteristic equation x3 = x + 1. The Perrin numbers bear the same relationship to the Padovan sequence as the Lucas numbers do to the Fibonacci sequence.

The number 6174 is known as Kaprekar's constant after the Indian mathematician D. R. Kaprekar. This number is renowned for the following rule:

  1. Take any four-digit number, using at least two different digits.
  2. Arrange the digits in descending and then in ascending order to get two four-digit numbers, adding leading zeros if necessary.
  3. Subtract the smaller number from the bigger number.
  4. Go back to step 2 and repeat.

In mathematics, a transformation of a sequence's generating function provides a method of converting the generating function for one sequence into a generating function enumerating another. These transformations typically involve integral formulas applied to a sequence generating function or weighted sums over the higher-order derivatives of these functions.

References