Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Kaprekar's routine
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Definition and properties== The algorithm is as follows:{{sfn|Kaprekar|1955}}{{sfn|Hanover|2017|loc=Methodology|p=3}} # Choose any four digit [[natural number]] <math>n</math> in a given [[number base]] <math>b</math>. This is the first number of the sequence. # Create a new number <math>\alpha</math> by [[Sorting algorithm|sorting]] the digits of <math>n</math> in descending order, and another number <math>\beta</math> by sorting the digits of <math>n</math> in ascending order. These numbers may have leading zeros, which can be ignored. Subtract <math>\alpha -\beta</math> to produce the next number of the sequence. # Repeat step 2. The sequence is called a Kaprekar sequence and the [[Function (mathematics)|function]] <math>K_b(n) = \alpha - \beta</math> is the '''Kaprekar mapping'''. Some numbers map to themselves; these are the [[Fixed point (mathematics)|fixed point]]s of the Kaprekar mapping,<ref name="A099009">{{OEIS|A099009}}</ref> and are called '''Kaprekar's constants'''. [[Zero (number)|Zero]] is a Kaprekar's constant for all bases <math>b</math>, 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, : <math>K_{10}(3524) = 5432 - 2345 = 3087</math> : <math>K_{10}(3087) = 8730 - 378 = 8352</math> : <math>K_{10}(8352) = 8532 - 2358 = 6174</math> : <math>K_{10}(6174) = 7641 - 1467 = 6174</math> 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 <math>\alpha</math> and <math>\beta</math> have the same [[digit sum]] and hence the same remainder modulo <math>b - 1</math>. Therefore, each number in a Kaprekar sequence of base <math>b</math> numbers (other than possibly the first) is a multiple of <math>b - 1</math>. When leading zeroes are retained, only [[repdigit]]s 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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)