The Kaprekar routine is an algorithm discovered in 1949 by D. R. Kaprekar for 4-digit numbers, but which can be generalized to k-digit numbers. To apply the Kaprekar routine to a number n, arrange the digits in descending (n') and ascending (n'') order. Now compute K(n) congruent n' - n'' (discarding any initial 0s) and iterate, where K(n) is sometimes called the Kaprekar function. The algorithm reaches 0 (a degenerate case), a constant, or a cycle, depending on the number of digits in k and the value of n. The list of values is sometimes called a Kaprekar sequence, and the result K(n) is sometimes called a Kaprekar number, though this nomenclature should be deprecated because of confusing with the distinct sort of Kaprekar number.