Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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??)

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
    
Your answer was quicker and has the general case as well, I will delete mine. I am glad, however, to see that I did not make any mistakes here. I usually do... :-) –  Asaf Karagila May 7 '11 at 18:03
    
I understand case 2, pretty straight-forward: 62^8, but your case 1 abit confuse, are you saying the possibility are: 62*61*60*59*58*57*56*55?? Is it same as @Asaf answer? –  FailMath May 7 '11 at 18:06
    
@Asaf, please dont delete your answer. You answer might be helpful to others users (I guess). But, as @Fahad answer first, and if its proven correct, I need to choose his answer as best answer, bcuz he is faster than you. Hope you dont mind. –  FailMath May 7 '11 at 18:08
    
Yes that's it. You cannot use any character you've used before, so the number of possibilities goes down each time. I'm fairly sure Asaf wrote the same thing. –  Sputnik May 7 '11 at 18:10
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. :-) –  Asaf Karagila May 7 '11 at 18:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.