The number 3211000 is 7-special

1.3k Views Asked by At

Define a positive integer $k$ to be $n$-special if it satisfies the following properties:

  1. It has $n$ digits (0, 1, ..., 9)
  2. The 1st digit is equal to the number of 0's in the decimal representation of $k$, the second digit is equal to the number of 1's, the third digit is equal to the number of 2's, etc

For instance, the number $3211000$ is $7$-special (since there are three 0's, two 1's, one 2, and one 3).

Questions:

  1. How many $7$-special numbers are there? Can you prove it?

  2. For what positive integer $n$ does there not exist any $n$-special numbers?

  3. Is there an efficient algorithm to compute all $n$-special numbers, given any positive integer $n$?

Have fun and enjoy! :)

2

There are 2 best solutions below

0
On

Just for kicks, I googled the 10-digit example (6210001000) that I mentioned in the comment, and found that these n-special numbers are apparently called self-descriptive numbers.

For your part 1), it doesn't list any other examples for 7, and judging from the OEIS list, there aren't any others. (As a heads-up, there's some base conversion going on in the list; your example is listed as 389305 (which gives 3211000 in base 7))

(Addendum: This list gives the numbers as you actually want them, though there are a few less entries)

For part 2), the article lists the three values of $n$ without any (2,3,6, though I guess 1 doesn't either if you want to count it)

For part 3), the article gives a general formula for getting more examples in higher bases, but only one per value of $n$. If I find anything about generating all (either more formulas or a proof that this is all of them), I'll update the answer. The formula itself is

$$(n-4)n^{n-1} + 2n^{n-2} + n^{n-3} + n^3$$

0
On

Here's a proof there are no other $7$-special numbers.

In a $7$-special number $a_0a_1a_2a_3a_4a_5a_6$, each $a_k$ counts the number of numerals that appear $k$ times among the digits. Since there are $7$ digits in all, we have

$$0a_0+1a_1+2a_2+3a_3+4a_4+5a_5+6a_6=7$$

This immediately implies $a_4+a_5+a_6\le1$, so at least two of those digits are $0$'s and at most one is a $1$. Now if any of them are equal to $1$, then one of the other digits is at least $4$. To satisfy the displayed equation, that digit can only be the $a_0$. We also have $a_1\ge1$. But we can't have $a_1=1$, since we already have at least one $1$, so we must have $a_1\ge2$. This means there are at least two $1$'s among the digits, the next one being either $a_2$ or $a_3$. But this leaves at most three digits that can possibly be $0$'s, which contradicts the conclusion $a_0\ge4$.

So we now know that $a_4=a_5=a_6=0$. This means there are at least three $0$'s among the digits, hence $a_0\ge3$. On the other hand, it also means that there are no $4$'s, $5$'s, or $6$'s among the digits, so $a_0$ cannot be any of those numerals. Hence we must have $a_0=3$. This implies that $a_1$, $a_2$, and $a_3$ are all at least $1$. Writing them as $a_k=1+b_k$ and plugging into the displayed equation (along with the established values $a_0=3$ and $a_4=a_5=a_6=0$), we find

$$b_1+2b_2+3b_3=1$$

This is clearly enough to conclude that $3211000$ is the only $7$-special number.

There are plenty of other ways to let the logic of this argument run. I'd be quite happy to see something shorter and more to the point.