# How many passwords with maximum length $8$ can be formed from upper case letters, lower case letters, digits, or hyphens?

The password for the security access to a vault is a multi-character string consisting of a combination of uppercase letters, lowercase letters, digits or hyphens. The rule on creating the password is that the first character in the string must be either a digit or lowercase letter or uppercase letter. The password length has maximum characters of eight (8). How many different combinations of passwords are there?

Here Hyphen is making problem to solve . How I can fix it?

• – user53259
Commented Jan 6, 2022 at 8:41

There are $63$ ($26 + 26 + 10 +1$) allowed characters. Only one is forbidden on the first place (hyphen).

So there are 62 passwords of length 1.

There are $62 \times 63$ passwords of length 2.

There are $62 \times 63 \times 63$ passwords of length 3, etc.

Now sum up to and including length 8 (and use a formula for a finite sum of this type, if you know it).

To expand on the last bit: note that for $a \neq 1$: $1 + a + a^2 + \ldots + a^k = \frac{a^{k+1}-1}{a-1}$ (proof: multiply both sides by $a-1$). In the sum, get the 62 out, and use this result to see we can write is directly as $63^8 - 1$.

The latter suggests a direct proof of that fact. Consider all sequences of all 63 allowed characters of length 8. Remove all consecutive hyphens from the start onwards. This gives all allowed passwords exactly once. The only problem is the all hyphen word, which would result in the empty password (which I assume is not allowed). Hence $63^8 - 1$.

• That means 62*63^7 will be the answer? Commented Oct 28, 2015 at 12:21
• @YasinArafat That is the number of exactly length 8. You need all lengths up to 8. So sum up. Commented Oct 28, 2015 at 12:22
• 62+62*63+62*63^2+................+62*63^7 ...I think I have got you :) Commented Oct 28, 2015 at 12:26
• @YasinArafat and this can be computed more simply using finite geometric series, if you know them... Commented Oct 28, 2015 at 12:27
• Actually dont have idea about this .If you excuse me, will you give a sample solution with this ? By the way Thankyou :) Commented Oct 28, 2015 at 12:30