A user must choose $n$ characters password using:

1. uppercase letters $A-Z (size=26)$
2. lowercase letters $a-z (size=26)$
3. digits $0-9 (size=10)$

Each password must contain at least an uppercase and a digit.

What should be the formula to calculate number of valid passwords of size $n$, give $n >= 1$ ?

I have calculated it to be:

Uppercase x Digit x combination of all 3 types = $26\times10\times(26\times26 \times10)^{n}$

• Hint: How many passwords of size 1 are there? What does your formula say? – Mees de Vries Nov 27 '16 at 15:43
• hmm it should be 0 but the formula gives a rather large number – KillerKidz Nov 27 '16 at 15:45

The easiest way to do this is probably inclusion-exclusion. There are $62^n$ strings of length $n$ using the characters provided. There are $36^n$ such strings without an uppercase letter, and $52^n$ such strings without a lowercase letter, and $26^n$ such strings without either.
Thus, the total number of valid passwords of length $n$ is $$62^n - 36^n - 52^n + 26^n,$$ where you add the number of strings without either back in, because you have subtracted it twice.
The answer should be calculated as all possible combinations $(26+26+10)^n$, minus the incorrect ones (no uppercase, no digits).