Logo
Overview

The Magic Number of Kaprekar

April 10, 2024
1 min read

D.R. Kaprekar and 6174

D.R. Kaprekar, an Indian mathematician, discovered a magical property of 4-digit numbers.

The Algorithm

  1. Pick any 4-digit number with at least two different digits (e.g., 63826382).
  2. Arrange digits in descending order to make the largest number (86328632).
  3. Arrange digits in ascending order to make the smallest number (23682368).
  4. Subtract the smaller from the larger.
  5. Repeat with the result.

Flowchart of the Process

Yes

No

Yes

No

Start with 4-digit number

Are all digits same?

Stop: Will result in 0

Arrange descending: A

Arrange ascending: B

Calculate C = A - B

Is C = 6174?

End: Reached Kaprekar Constant!

Use digits of C

Example Walkthrough

Let’s try with 35243524.

  1. Digits: 5,4,3,25, 4, 3, 2.
    • 54322345=30875432 - 2345 = 3087
  2. Digits from 30873087: 8,7,3,08, 7, 3, 0.
    • 87300378=83528730 - 0378 = 8352
  3. Digits from 83528352: 8,5,3,28, 5, 3, 2.
    • 85322358=61748532 - 2358 = 6174
  4. Digits from 61746174: 7,6,4,17, 6, 4, 1.
    • 76411467=61747641 - 1467 = 6174 (It repeats!)
Tip

Try it yourself: How many steps does your birth year take to reach 6174?