3
$\begingroup$

I am new to web development.

I am still on planning stage. One of the question that bug me is, lets say: the username can only contains 8 characters and each characters is not allowed special characters (@#$%^&), it only allows lower case "a-z", upper case "A-Z", and numerical number from "0-9". How many users I can have and how do u calculate it?

Case 1: Characters cannot be repeated eg "abcdefgh", "a1b2c3d4" etc

Case 2: Characters can be repeated, eg. "AAbbccdd", "a1b1c1D1" etc

FYI, the 8 just a sample number, of course the bigger number I provide, the better it is, but I am just curious and my math sucks :(

(I assume, need to use permutations??)

1 Answers 1

7

There are 26 uppercase letters, 26 lowercase letters, and 10 numerical digits, giving 62 possibilities for each of the eight characters. So there are $62\times 62\times \ldots \times 62 = 62^8$ possible usernames, which is a massive number.

This is in case 2, when anything goes. In case 1, once you have chosen a character, you are left with 61 possibilities for the next, then 60 possibilities for the next, giving the answer as $62\times 61\times \ldots \times 55$ usernames.

In general, therefore, with a string of $n$ characters you have $62^n$ possible usernames. With no repetitions, this becomes $\frac{62!}{(62-n)!}$ usernames.

  • 2
    @FailMath: My answer was exactly as Fahad's only without regarding the general case. I don't see how two duplicate answers are useful here. :-)2011-05-07