How many passwords with one or more digits?

A symbol in a password is either one of $$26$$ latin letters or one of $$10$$ digits. How many $$8$$ symbol passwords with at least $$1$$ digit?

I know there are $$36^8-26^8$$ of them. But at first I thought there were $$36^7\times 10$$.

What was my mistake? What does the number $$36^7\times 10$$ represent?

The whole length $$8$$ password space has size $$36^8$$. There are $$26^8$$ passwords with only letters and no digits. So $$36^8 - 26^8$$ counts the number of passwords with at least one digit.

$$10\cdot 36^7$$ counts the number of passwords with a digit at the first position, e.g. Or with a digit at the final position. Or any fixed pre-given position for that matter.

To count the number with at least one letter we have the substract the
number of passwords with only digits, so $$36^8-10^8$$.

• Ah, ok, so it's at any position vs at a fixed position. But I still don't understand why $38^7\times 10$ doesn't answer the question. Why is it a wrong answer? Why can't numbers with a digit in a fixed position count as the answer to this question? – Coder-Man Sep 25 '18 at 8:16
• @Coder-Man Because if we only count those with a starting digit we miss many passwords, like a1bbbbbb, which would also be a valid one. – Henno Brandsma Sep 25 '18 at 8:20
• Oh! Stupid me, now I get it. Thank you very much. – Coder-Man Sep 25 '18 at 8:22
• @Coder-Man We could multiply by $8$ for all positions but then we'd double count a password like 12abbbbb which you would count among the passwords with digit at position 1 and at position 2 as well. – Henno Brandsma Sep 25 '18 at 8:22
• But how come, even though, as you said, we miss passwords like a1bbbbbb, $38^7\times 10 > 38^8-26^8$? – Coder-Man Sep 25 '18 at 8:28

$$36^7 \times 10$$ represents all passwords with one number in a chosen position. For $$7$$ of the places you choose from all possible letters and numbers and for the chosen one you choose only from the numbers.

Assuming your title is correct and you are looking for passwords containing one or more digits, then $$36^8 -26^8$$ represents the space of all possible passwords minus those which are completely made up of letters.

Similarly, if you were looking for passwords containing one or more letters, then the answer would be $$36^8-10^8$$, the space of all passwords minus those which are completely made up of numbers.

• How is that different from what $36^8-26^8$ represents? – Coder-Man Sep 25 '18 at 7:59
• You didn't write it correctly, I didn't say it's $36^8-10^8$ – Coder-Man Sep 25 '18 at 8:00
• @Coder-Man I am asking you if that is what you meant? $36^8-26^8$ is all passwords containing a number not a letter – lioness99a Sep 25 '18 at 8:01
• not at least one number, but say a number at the final position. You cannot choose the digit position freely. – Henno Brandsma Sep 25 '18 at 8:03
• Title ask for password with a number, and question body ask for password with a letter. I think OP made a typo, but from the results he gets, the title seems to be correct – F.Carette Sep 25 '18 at 8:03