Find number of numerical digits in all possible hexadecimal numbers of length n

127 Views Asked by At

As stated in question, find number of digits in all possible hexadecimal numbers of length n.

If n = 1; out of 1 to F we have 9 ( exclude digits starting with 0 ) If n = 2; 11 to 1F - we have 26 digits and so on..

There seems to be a pattern that i was unable to formulate.

If we consider hexadecimal numbers of length 1 we need to exclude 0 and start from 1 to F ( each of 1 to 9 have 1 digit and none from A to F have any digits in it ) if we check from 10 to 1F ( each number from 10 to 19 has two digits in it and each number from 1A to 1F have 1 digit in it )

1

There are 1 best solutions below

3
On

There are $15\cdot16^{n-1}$ numbers having $n$ hexadecimal digits. At the first place ${9\over15}$ of these have a numerical digit, and at the following $n-1$ places ${10\over16}$ of these have a numerical digit. It follows that the number $N_n$ you are after is given by $$N_n=15\cdot 16^{n-1}\left({9\over15}+(n-1){10\over16}\right)\ .$$