Friday, June 19, 2026

Constant.

 6174 is one of the most fascinating numbers in recreational mathematics. It is called Kaprekar's Constant, named after the Indian mathematician Dattatreya Ramchandra Kaprekar. 

Take almost any 4-digit number with at least two different digits.

For example, start with 3524:

Arrange digits in descending order: 5432

Arrange digits in ascending order: 2345

Subtract: 5432 − 2345 = 3087

Now repeat:

8730 − 0378 = 8352

8532 − 2358 = 6174

Once you reach 6174, it stays there forever:

7641 − 1467 = 6174 

This happens for almost every four-digit number and takes at most seven steps. The only exceptions are numbers with all digits the same, such as 1111, 2222, or 9999. 

Many people call 6174 a "mathematical black hole" because numbers seem to be irresistibly drawn toward it. 

Since you also enjoy the symbolism of numbers, you may find this coincidence delightful:

6 + 1 + 7 + 4 = 18

1 + 8 = 9

And as you mentioned recently, 9 has a special place in many spiritual and mathematical traditions. Of course, that connection is symbolic rather than part of Kaprekar's mathematical proof. 

What is perhaps most remarkable is that this mysterious number was discovered not by a famous university professor but by an Indian schoolteacher who loved playing with numbers and patterns. 

Kaprekar Number

A Kaprekar number is a number whose square when divided into two parts and such that sum of parts is equal to the original number and none of the parts has value 0.

Given a number, the task is to check if it is Kaprekar number or not.

Examples: 

Input : n = 45 

Output : Yes

Explanation : 452 = 2025 and 20 + 25 is 45

Input : n = 13

Output : No

Explanation : 132 = 169. Neither 16 + 9 nor 1 + 69 is equal to 13

Input : n = 297 

Output : Yes

Explanation: 2972 = 88209 and 88 + 209 is 297

Input : n = 10 

Output : No

Explanation: 102 = 100. It is not a Kaprekar number even if

sum of 10 + 0 is 10. This is because of the condition that 

none of the parts should have value 0. 

Approach:Find square of n and count number of digits in square.Split square at different positions and see if sum of two parts in any split becomes equal to n.

Below is implementation of the idea.

//C++ program to check if a number is Kaprekar number or not

#include<bits/stdc++.h>using namespace std;​// Returns true if n is a Kaprekar number, else falsebool iskaprekar(int n){ if (n == 1) return true;​ // Count number of digits in square int sq_n = n * n; int count_digits = 0; while (sq_n) { count_digits++; sq_n /= 10; }​

Dattatreya Ramchandra Kaprekar (Marathi: दत्तात्रेय रामचंद्र कापरेकर; 17 January 1905 – 4 July 1986) was an Indian recreational mathematician who described several classes of natural numbers including the Kaprekar, Harshad and self numbers and discovered Kaprekar's constant, named after him. Despite having no formal postgraduate training and working as a schoolteacher, he published extensively and became well known in recreational mathematics circles.

A similar constant for three digits is 495.[8] However, in base 10 a single such constant only exists for numbers of 3 or 4 digits; for other digit lengths or bases other than 10, the Kaprekar's routine algorithm described above may in general terminate in multiple different constants or repeated cycles, depending on the starting value.[9] For example, for 2-digit numbers, the numbers eventually enter a loop, for example:

31 − 13 = 18However, if in the above example 9 is not treated as a two-digit number (09), all two-digit numbers will end at 9. All differences between two-digit number digital swaps are multiples of 9, and thus will immediately enter the loop above at some stage. (Notably, both 495 and 6,174 are multiples of 9.)

Kaprekar numberedit

Main article: Kaprekar number

Another class of numbers Kaprekar described are Kaprekar numbers.[10] A Kaprekar number is a positive integer with the property that if it is squared, then its representation can be partitioned into two positive integer parts whose sum is equal to the original number (e.g. 45, since 452=2025, and 20+25=45, also 9, 55, 99 etc.) However, note the restriction that the two numbers are positive; for example, 100 is not a Kaprekar number even though 1002=10000, and 100+00 = 100. This operation, of taking the rightmost digits of a square, and adding it to the integer formed by the leftmost digits, is known as the Kaprekar operation.

Some examples of Kaprekar numbers in base 10, besides the numbers 9, 99, 999, ..., are (sequence A006886 in the OEIS):

NumberSquareDecomposition703703² = 494209494+209 = 70327282728² = 7441984744+1984 = 2728

Devlali or self numberedit

Main article: Self number

In 1963, Kaprekar defined the property which has come to be known as self numbers,[11] as the integers that cannot be generated by taking some other number and adding its own digits to it. For example, 21 is not a self number, since it can be generated from 15: 15 + 1 + 5 = 21. But 20 is a self number, since it cannot be generated from any other integer. He also gave a test for verifying this property in any number. These are sometimes referred to as Devlali numbers (after the town where he lived); though this appears to have been his preferred designation,[11] the term "self number" is more widespread. Sometimes these are also designated Colombian numbers after a later designation.

Harshad numberedit

Main article: Harshad number

Kaprekar also described the harshad numbers which he named harshad, meaning "giving joy" (Sanskrit harsha, joy +da taddhita pratyaya, causative); these are defined by the property that they are divisible by the sum of their digits. Thus 12, which is divisible by 1 + 2 = 3, is a harshad number. These were later also called Niven numbers after 1977 lecture on these by the Canadian mathematician Ivan M. Niven. Numbers which are harshad in all bases (only 1, 2, 4, and 6) are called all-harshad numbers. Much work has been done on harshad numbers, and their distribution, frequency, etc. are a matter of considerable interest in number theory today.

Demlo numberedit

Kaprekar also studied the Demlo numbers,[12] name of which was derived from the name of a train station Demlo (now called Dombivili) 30 miles from Bombay on the then G. I. P. Railway where he had the idea of studying them.[2] The best known of these are the Wonderful Demlo numbers 1, 121, 12321, 1234321, ..., which are the squares of the repunits 1, 11, 111,1111, ....[13]



No comments: