*** Welcome to piglix ***

Self-descriptive number


In mathematics, a self-descriptive number is an integer m that in a given base b is b digits long in which each digit d at position n (the most significant digit being at position 0 and the least significant at position b - 1) counts how many instances of digit n are in m.

For example, in base 10, the number 6210001000 is self-descriptive because of the following reasons:

In base 10, the number has 10 digits, indicating its base;
It contains 6 at position 0, indicating that there are six 0s in 6210001000;
It contains 2 at position 1, indicating that there are two 1s in 6210001000;
It contains 1 at position 2, indicating that there is one 2 in 6210001000;
It contains 0 at position 3, indicating that there is no 3 in 6210001000;
It contains 0 at position 4, indicating that there is no 4 in 6210001000;
It contains 0 at position 5, indicating that there is no 5 in 6210001000;
It contains 1 at position 6, indicating that there is one 6 in 6210001000;
It contains 0 at position 7, indicating that there is no 7 in 6210001000;
It contains 0 at position 8, indicating that there is no 8 in 6210001000;
It contains 0 at position 9, indicating that there is no 9 in 6210001000.

There are no self-descriptive numbers in bases 1, 2, 3 or 6. In bases 7 and above, there is, if nothing else, a self-descriptive number of the form , which has b - 4 instances of the digit 0, two instances of the digit 1, one instance of the digit 2, one instance of digit b - 4, and no instances of any other digits. The following table lists some self-descriptive numbers in a few selected bases:


...
Wikipedia

...