# Password consists of 5 characters

Password consists of 5 characters, these characters can be a digit (0-9) and the letters ABC 26 letters. Each character can be repeated more than once. How many different passwords that have at least one digit and at least one letter?

I tried to think of it this way: $$10 * 26 * 36 ^ 3=12,130,560$$

Because there is at least one letter and one digit and hence have 36 other options ...

According to the book: $$36^5-[10^5+26^5]=48,484,800$$

• you want to count the numbers of passwords with 5 characters without restrictions it is $36^5$ minus the passwords with 5 letters ($26^5$ such passwords) and minus the passwords with 5 numbers ($10^5$ such passwords). – Jennifer Mar 28 '16 at 14:46
• Try to think of the different ways you can get the probability of a certain combination. Two common ways are by getting it directly by counting the number of allowed cases, or by getting it indirectly by starting with the probability of any combination and then subtracting whatever combinations are not allowed. – MathInferno Mar 28 '16 at 14:48
• I think that his question is not, why the second formula is correct, but rather why the first one is wrong. – ThorbenK Mar 28 '16 at 14:48
• An other approach would be te consider all the patterns possible : for example LNNLN (where L is a letter and N a number) and for each patter count all the possibilities, it would be an approach similar to your first idea but you have to consider a lot of patterns. – Jennifer Mar 28 '16 at 14:51
• And with you calculation you only count the passwords with the following patterns : NLXXX where X can be N or L, so you don't count "abc36" as a legit password for example. – Jennifer Mar 28 '16 at 14:58

The total number of sequences of 5 characters is $36^5$. Consider the sequences of 5 characters that are not valid passwords. There are two types of them: the sequences containing only digits ($10^5$ possible sequences) and the sequences containing only letters ($26^5$ possible sequences). This explains the (right) answer of the book.
Edit. If you want to use your method, you should decompose the cases as follows. Let $D$ denote a digit, $L$ a letter and $S$ any symbol. Then you may have the following mutually disjoint cases $$LDSSS, LLDSS, LLLDS, LLLLD, DLSSS, DDLSS, DDDLS, DDDDL$$ leading to the number $$26 \times 10 \times 36^3 + 26^2 \times 10 \times 36^2 + 26^3 \times 10 \times 36 + 26^4 \times 10 + 10 \times 26 \times 36^3 + 10^2 \times26 \times 36^2 + 10^3 \times 26 \times 36 + 10^4 \times 26 = 48484800$$ If you know automata theory, it is similar to finding the complement of a regular expression.
Either you calculate the possible ways by counting ($1N-4L$), ($2N-3L$), ($3N-2L$), ($4N-3L$) and you sum them. or you calculate the case where all situation could happen and subtract the the two cases where all are digits(no litter) and all litter(no digit) from the total case.