Thursday 25 October 2018

Self Numbers and Junction Numbers

Today I turned 25407 days old and discovered from Numbers Aplenty that it is a self number or Columbian number. Such a number is defined as one that cannot be written as \(x+\mathrm{sod}(x) \) where \(\mathrm{sod}(\cdot) \) denotes the sum of digits. One is reminded immediately of an inconsummate number that cannot be written as \(x ÷ \mathrm{sod}(x) \) where \(\mathrm{sod}(\cdot) \) denotes the sum of digits. View my blog post about these latter numbers here.

Self numbers are base dependent. From Wikipedia:
In general, for even bases, all odd numbers below the base number are self numbers, since any number below such an odd number would have to also be a 1-digit number which when added to its digit would result in an even number. For odd bases, all odd numbers are self numbers. The set of self numbers in a given base q is infinite and has a positive asymptotic density: when q is odd, this density is 1/2.
D.R.Kaprekar, who introduced these numbers in 1949, gave the following test to determine quickly if a number is self.

Define the functions
\[
\begin{array}{lcl}
d(n)& = & \mathrm{the\ number\ of\ digits\ of\ }n\,,\\[1mm]
r(n)\vphantom{M^{M^M}a_{M_M}}&=& 1+({{(n-1)}\pmod9})\,, \\[1mm]
h(n)&=&\left\{%
\begin{array}{ll}
r(n)/2&\mathrm{\ if\ }r(n)\mathrm{\ is\ even}\,,\\
(r(n)+9)/2&\mathrm{\ if\ }r(n)\mathrm{\ is\ odd}\,.\\
\end{array}\right.\\
\end{array}
\]Then a number \(n\)  is self if, for every \(k=0,1,\dots,d(n)\), it holds
\[
\mathrm{sod}(|n-h(n)-9\cdot k|) \neq h(n)+9\cdot k\,
\]where \(|x|\)  denotes the absolute value of \(x\).

Kaprekar's algorithm of course makes it very easy to write the necessary SAGE code to identify self numbers within a given range of numbers. Here is the code that I developed:


If the SAGE code runs in the SAGE CELL window (sometimes there are glitches), you'll see the output 25407 25418 25420 25431 25442 and so 25418 marks the next occurrence of a self number. The first self numbers (OEIS A003052) are:
1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, 97, 108, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 211, 222, 233, 244, 255, 266, 277, 288, 299, 310, 312, 323, 334, 345, 356, 367, 378, 389, 400, 411, 413, 424, 435, 446, 457, 468, 479, 490, 501, 512, 514, 525
A self prime is a self number that is prime (OEIS A006378). The first few self primes are:
3, 5, 7, 31, 53, 97, 211, 233, 277, 367, 389, 457, 479, 547, 569, 613, 659, 727, 839, 883, 929, 1021, 1087, 1109, 1223, 1289, 1447, 1559, 1627, 1693, 1783, 1873, ... 
Again from Wikipedia: "In October 2006 Luke Pebody demonstrated that the largest known Mersenne prime that is at the same time a self number is \(2^{24036583}−1 \). This is then the largest known self prime as of 2006."

By contrast, a junction number is one that can be written in more than one way as  \(x+\mathrm{sod}(x) \). For example, \(818 \)  is a junction number because it has two generators, \(796 \) and \(805 \). Indeed \[796+7+9+6 = 805+8+0+5 = 818.\]The first junction numbers are:
101, 103, 105, 107, 109, 111, 113, 115, 117, 202, 204, 206, 208, 210, 212, 214, 216, 218, 303, 305, 307, 309, 311, 313, 315, 317, 319, 404, 406, 408, 410, 412, 414, 416, 418, 420, 505, 507
It's easy enough to modify the previous SAGE code so that a list of junction numbers within a given range is generated:


The output generated from this code should be 101 103 105 107 109 111 113 115 117 together with the two smaller numbers that produce them. The junction numbers occur in runs of nine odd numbers and this is clearly seen in Figure 1 that shows the graph of such numbers between 1 and 1000.


Figure 1

Kaprekar's original paper can be viewed here.

No comments:

Post a Comment