I stuck at a problem Problem 162
I tried Like this..
Let length of number of be n
Numbers starting with $0$ will be 15^(n-1).Now we will subtract this from Total because these are invalid numbers.
Number that contain at least one A, one $1$ and one $0$ =>$\binom{n}{3}$ for choosing pos for $01A$ and arrange them in 3 factorial ways
we can fill remaining n-3 positions with 16^(n-3) ways
So answer =$ \binom{n}{3}$* $3!$ * 16^(n-3) - 15^(n-1)
which is coming out to be negative for n=4. Please help
There are two ways in which you went wrong.
Firstly, your method of counting numbers which contain at least one A, one 1 and one 0 double-counts those numbers which have more than one A, 1, or 0.
Secondly, when you subtract those with leading zeroes, you should only subtract those that were already erroneously counted in the first place by the other calculations. You are also subtracting those with leading zeroes that don't even contain any A for example. I also don't see why you are using $15^{n-1}$ and not $16^{n-1}$ - it seems to suggest you are subtracting only those numbers with a leading zero and no other zeroes at all.
I won't go into detail about how to do this problem correctly, as spoiling problems is against the spirit of PE, but I will give a hint: the Inclusion-Exclusion principle.