Execute a structured sorting and subtraction algorithm to reach a constant.
Introduce D.R. Kaprekar and his 1949 discovery.
D.R. Kaprekar was a mathematics teacher in a government school in Devl school in Devlali, Maharashtra. He loved playing with numbers and found many beautiful, previously unknown patterns.
Trace the algorithm for the number 6382.
Execute Kaprekar's routine starting with the 4-digit number .
Mathematician Kaprekar showing the flow chart for Kaprekar's constant in the classroom

The repetitive cycle of arranging and subtracting digits.
Apply the routine to a 3-digit number to find its constant.
Let's execute the steps to find the 3-digit Kaprekar constant starting from 321.
First, sort the digits of 321 in descending and ascending order, then subtract. The first step gives 321 - 123 = 198.
Using the result 198, the next step is 981 - 189 = 792. Continuing the process, the next subtraction is 972 - 279 = .
Taking that result, we calculate 963 - 369 = .
Eventually, this sequence will reach a number that starts repeating itself. The 3-digit Kaprekar constant that repeats is .
Count the iterations for a specific number.
Goal: Use Kaprekar's routine starting with 5683.
In each round:
Reminder: Always keep the number as 4 digits. If you get a 3-digit number, add a zero at the front before sorting again.
Make the biggest possible number using the digits 5, 6, 8, and 3.
Make the smallest possible 4-digit number using the same digits.
This gives the result of Round 1.
For each new number, arrange digits in descending and ascending order, then subtract.
Count how many subtractions were needed.