-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkaprekars-routine.txt
More file actions
71 lines (46 loc) · 2.49 KB
/
kaprekars-routine.txt
File metadata and controls
71 lines (46 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Have you ever played with numbers and found a surprising pattern? One such fascinating pattern is hidden within **Kaprekar's Routine**, named after the Indian mathematician D.R. Kaprekar. It's a simple game that, for most four-digit numbers, always leads to the same result: **6174**.
Let's dive in and see how it works!
## The Rules of the Game
1. **Pick a four-digit number** with at least two different digits. (Numbers like 1111, 2222, etc., won't work).
2. **Arrange the digits** to form the largest possible number.
3. **Arrange the same digits** to form the smallest possible number.
4. **Subtract** the smallest number from the largest number.
5. **Repeat** steps 2-4 with the new number you get.
You'll be amazed at what happens!
## Example 1: Starting with 3524
Let's try with the number **3524**:
* **Step 1:** Our number is 3524. It has different digits.
* **Step 2:** Largest number: 5432
* **Step 3:** Smallest number: 2345
* **Step 4:** Subtract: 5432 - 2345 = **3087**
Now, we repeat the process with **3087**:
* **Step 2:** Largest number: 8730
* **Step 3:** Smallest number: 0378 (remember to include leading zeros to keep it a four-digit number)
* **Step 4:** Subtract: 8730 - 0378 = **8352**
Repeat with **8352**:
* **Step 2:** Largest number: 8532
* **Step 3:** Smallest number: 2358
* **Step 4:** Subtract: 8532 - 2358 = **6174**
And there it is! We reached 6174.
## Example 2: Starting with 1987
Let's try another one with **1987**:
* **Step 1:** Our number is 1987.
* **Step 2:** Largest number: 9871
* **Step 3:** Smallest number: 1789
* **Step 4:** Subtract: 9871 - 1789 = **8082**
Repeat with **8082**:
* **Step 2:** Largest number: 8820
* **Step 3:** Smallest number: 0288
* **Step 4:** Subtract: 8820 - 0288 = **8532**
Repeat with **8532**:
* **Step 2:** Largest number: 8532
* **Step 3:** Smallest number: 2358
* **Step 4:** Subtract: 8532 - 2358 = **6174**
Again, we arrived at 6174!
## The Magic of 6174
This number, 6174, is known as **Kaprekar's Constant**. For almost any four-digit number (with at least two different digits), if you keep applying Kaprekar's routine, you will eventually reach 6174. Once you reach 6174, the next step will always be:
* Largest: 7641
* Smallest: 1467
* Subtract: 7641 - 1467 = **6174**
It's a loop!
Kaprekar's routine is a wonderful example of how simple arithmetic operations can lead to unexpected and beautiful mathematical constants. Try it with your own four-digit numbers and see the magic unfold!