The Magic Number 6174 That Never Goes Away
A simple math trick discovered by Indian mathematician D. R. Kaprekar

A developer who writes somethings useful.
Search for a command to run...
A simple math trick discovered by Indian mathematician D. R. Kaprekar

A developer who writes somethings useful.
No comments yet. Be the first to comment.
Welcome to the Crawl Budget Circus! 🎪 Step right up, ladies and gentlemen! Today, we’re diving into the thrilling world of crawl budgets—the magical limit that determines how much time Googlebot spends crawling your website. Think of it as a circus ...

Efficiency at Your Fingertips in Visual Studio Code

Tracing the Roots of the World Wide Web and HTML Evolution

Unlocking Unpopular Functions in JavaScript for Better Code

Last night while checking out a YouTube video, the algorithm suggested a video about the 6174 magic number—also known as Kaprekar's constant. Since the word "magic" always catches my attention, I gave it a watch. And wow, this number really is magic! It’s so simple and fun that you can play around with it with your friends, kids, or anyone, really.
Let’s dive straight into the details.
The number 6174 is known as Kaprekar’s constant, and it has a special trick. If you take almost any 4-digit number, follow a few simple steps, and repeat them, you will always end up with 6174. No matter what!
Here’s how it works:
Pick a 4-digit number (it can’t have all the digits the same, like 1111 or 2222).
Rearrange the digits to make the biggest number possible and the smallest number possible.
Subtract the smallest number from the biggest number.
Repeat the process with the new number you get, and after a few rounds, you’ll reach 6174.
Let’s break it down super simply. Imagine you have a 4-digit number like 3524. Here’s what you do:
First, rearrange the digits so you get the largest and smallest numbers.
Largest: 5432
Smallest: 2345
Now subtract the smallest from the largest:
5432 - 2345 = 3087
Now do the same thing with the new number, 3087.
Largest: 8730
Smallest: 0378 (which is just 378)
Subtract them:
8730 - 378 = 8352
Now take 8352 and repeat the process:
Largest: 8532
Smallest: 2358
Subtract:
8532 - 2358 = 6174
And that’s it! You’ve reached the magic number 6174. If you keep going, you’ll always get 6174 no matter how many times you repeat the steps.
Try it out for yourself, you can check out this CodePen and play around with Kaprekar's constant right in your browser.
The magic of 6174 was discovered by an Indian mathematician named D. R. Kaprekar in 1949. He loved finding interesting patterns in numbers, and this one is his most famous discovery. It’s a fun trick that shows how math can surprise us in unexpected ways.
India has contributed a lot to mathematics, from the invention of the number zero to the brilliant work of mathematicians like Srinivasa Ramanujan. Kaprekar’s constant is another reminder that math can be playful and full of cool discoveries, even when it seems simple.