A self-descriptive number is an integer m in which each digit d at position n (the most significant digit being at position 0 and the least significant at position 9 ) counts how many instances of digit n are in m . The smallest self-descriptive number is 1 2 1 0 , as it has 1 zero, 2 ones, 1 two and 0 threes. Find the largest self-descriptive number.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Why 9000000000 can't be self descriptive
sir please tell me what about 8000000010, it is larger than your number+8 is at 0th position and contains 8 zeroes+1 is at 8th place and contains one 8, then why this is not correct answer,reply please............
Log in to reply
your number has a 1 too hence a 1 should come right after 8 and hence does not satisfy....
We have that to maximize n , so n have 10 digits. Be n = a 1 a 2 a 3 ⋯ a 1 0 , is autodescriptive so a 1 + ⋯ + a 1 0 = 1 0 . If a 1 = 9 , then a 2 + ⋯ + a 1 0 = 1 , but is not posible, because a 1 0 = 1 and a 2 = 1 . Contradiction. If a 1 = 8 , then a 2 + ⋯ + a 1 0 = 2 , but is not posible, because a 9 = 1 and a 2 = 2 and a 2 = 1 . Contradiction. If a 1 = 7 , then a 2 + ⋯ + a 1 0 = 3 , but is not posible, because a 8 = 1 and a 2 = 2 and a 2 = 1 . Contradiction. If a 1 = 6 , then a 2 + ⋯ + a 1 0 = 4 , is posible, when n = 6 2 1 0 0 0 1 0 0 0 .
Hi. I like your explanation. Simple and straightforward. I just want to ask where is the property a(1) + ... + a(10) = 10 derived?
Log in to reply
You have a ten digit number, so the sum of all digits also has to be ten since it is only adding the number of digits.
Great explanation Ricardo. I was surprised none realized the sum of all digits principle until I scrolled down to your solution..
We want to number to be as large as possible. First, we try to place 9 at the most significant digit.
9000000000
0123456789
This can't work because there is 1 nine and there have to be 9 zero's for the number to be self descriptive.
Then, we try 8 .
8200000010
0123456789
This only has 7 zeros but we need 8 .
After iterating a couple of times, we find a suitable candidate at a number that starts with 6 . Now, this number has to be the greatest because we tried and failed for number that start with 9 , 8 , 7 . Any other combination that we try will be < 6 2 1 0 0 0 1 0 0 0 . Thus, finally we get 6 2 1 0 0 0 1 0 0 0 .
why cant we put 9000000000
Log in to reply
9000000000
has
1
nine and
9
zeros. But in the
9
th
position, it shows
0
instead of
1
, that is,
9000000001
would have been right if there were 9 zeros. But there are only 8 zeros here. Thus, we can't make a self descriptive number with 9 in the first digit.
Log in to reply
oh yeah rite i forgot to put 1 for 9 in number....thanx
Note two things first -
i) It can not have more than ten digits. ii) It should have maximum zeroes.
Step 1. Let's try nine zeroes
9000000000
But it should be 9000000001, because there is one '9' (yes, this is also wrong but we have to get the first digit first). But now there are 8 zeroes.
Step 2. Now let's try eight zeroes.
8000000010
But it should be 8100000010, because there is one '1'. But now there are 7 zeroes.
Step 3. Now let's try seven zeroes
7100000100
But it should be 7210001000, because there are two '1's and one '2'. But now there are 6 zeroes.
Step 4. Let's try Six zeroes, then.
6210001000
Yep, that's the answer.
Explanation for maximum 10 Digits -
So, there are only 10 digits possible
Log in to reply
Thank you for this easy explanation. I needed it.
But the answer is not the largest self-descriptive number. You should think on these self-descriptive numbers, 72100001000, 821000001000 and so on, What do you say?
dude, as we know, the question says "digit" which mean single digit(0-9), e.g. 72100001000, the last digit of this number express the number of digit "10". Since "10" is not single digit your argument is flaw. CMIIW
could you please give clear explanation?
You should clarify that the number can have a maximum of 10 digits. One could interpret the problem as saying that (for example) the 11th digit (digit number 10), which indicates how many times the digit "10" appears in the number, must equal the number of times the two-digit string "10" occurs, or that it must equal zero because "10" is not a digit, so of course the digit "10" appears zero times. Using the latter interpretation (which is the interpretation I first assumed) the answer would be 9210000001000. I haven't tried to solve the problem with the former interpretation.
Problem Loading...
Note Loading...
Set Loading...
I played the following game (having in mind that if one wants to maximize, then take a 1 0 -digit number):
0 0 0 0 0 0 0 0 0 0
One starts putting something in the 9 th position. Logically, we only can put 1 . Otherwise, we would get a number with more than 1 0 digits. The same logic applies for the 8 th , 7 th and 6 th positions. So we put 1 and we try whatever would imply putting that 1 .
For example, putting 1 on the 9 th position implies having a 9 on the 0 th position, and then the number doesn't works because we would get 8 zeroes, which contradicts having a 9 on the 0 th position. So we pass to the eight position, and seventh position, and similar things will occur (deserves long explanation, but is the same idea... sorry im lazy to write). When we get to the 6 th position, we are able to put a 6 on the 0 th position, while we have 8 zeroes. On the 1 th position we put a 2 , and on the 2 th position a 1 . That is:
6 2 1 0 0 0 1 0 0 0
So we've maximized... the answer: 6 2 1 0 0 0 1 0 0 0 .