There is this example in my text for counting, and I understand the solution they have given. But I can't seem to find the mistake in my initial understanding which gives a different solution which I know must be wrong. I think it is important I understand where my intuition went wrong.

Q Each user on a computer system has a password, which is six to eight characters long, where each character is an uppercase letter or a digit. Each password must contain at least one digit. How many possible passwords are there?

My solution was $(10 \cdot 36^5) + (10 \cdot 36^6) + (10 \cdot 36^7)$ where I thought that if I kept one slot for only digits,giving 10 choices for it,the rest of the slots could have 36 choices each.

The correct solution :

$P6 = 36^6 − 26^6 = 2,176,782,336 − 308,915,776 = 1,867,866,560$

Similarly, we have

$P7 = 36^7 − 26^7 = 78,364,164,096 − 8,031,810,176 = 70,332,353,920$


$P8 = 36^8 − 26^8 = 2,821,109,907,456 − 208,827,064,576 = 2,612,282,842,880$


$P = P6 + P7 + P8 = 2,684,483,063,360$

Please help me understand where my solution is wrong?

P.S. I found this SO question , but the answers didn't quite help understanding my fault except the one by Mark but I need more clarification but not enough rep to comment there.

  • $\begingroup$ you can use $\cdot$ in place of *. maybe it's looking for combinations not permutations so some selections of the values would be the same ... $\endgroup$ – user451844 Jul 26 '17 at 2:36
  • $\begingroup$ You made two types of errors: You did not consider the positions of the digits and counted arrangements with more than one digit multiple times, once for each way you could designate one of the digits as the digit that goes in the slot you reserved for a digit. $\endgroup$ – N. F. Taussig Jul 26 '17 at 13:10

Notice that keeping one slot just for digits will not count what you want, since the digit may change in the position of the answer (they don't have to be all in the first position, for instance, and you're not considering the passwords that have letters in the position where you fix the number). A correct way to compute the solution is to first compute all the possible passwords in $n$ characters, that is, $36^n$, and then subtract all the possible passwords that do not have any numbers, which are the ones that only have letters, which are $26^n$. You then sum the acceptable lengths of the password.


your solution repeats some situations

one example:suppose that the first character is a digit

then when the second character is also a digit

it may be same as let the second one a digit while the first is a digit

in addition ,if there is only one character a digit ,where is it in the password,each position is possible ,so you should multiplied by 6


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.