Another how many combinations question - slightly more complicated

1. May 13, 2012

krytie75

Hi. I need a little help.

I'm trying to work out how many combinations of characters there are for a string that is between 1 and 8 characters long and uses a-z (non caps) and 0-9. There are 36 useable characters and the string could be anything from simply 'a' to '99999999'. I was able to work out how many combinations there would be if there were known to be 8 characters in the string, but I'm not sure how to include all the combinations before that (1 - 7 characters long). Is there a formula for this?

2. May 13, 2012

Mentallic

It's actually simpler than you think.

How many combinations are there if it's just 1 character length? 36
Two characters in length? Well the first can be any of the 36, and the second can be any of 36 as well, so it's 362
Three characters? Again applying the same idea, we get 363
...

And so we can get the total number of combinations by adding each and every value, so we have
$$36+36^2+36^3+...+36^8$$

And just as a reminder, we can evaluate this more simply by using the formula $$1+r+r^2+...+r^n=\frac{1-r^{n+1}}{1-r}$$

3. May 14, 2012

krytie75

Hi Mentallic!

Thanks for your help, it all makes perfect sense!

One thing I'm not quite sure on though...

When I use the formula you provided at the bottom of your response, I get the answer:

2901713047669

However when I manually calculate 36+36^2+...+36^8 I get the answer:

2901713047668

Which has a difference of 1. I'm guessing this has something to do with the "1+r+r^2" bit of your formula but I'm not sure why?

Thanks again!

4. May 14, 2012

Mentallic

If you use the formula, you should get 2901713047668 as the answer should be. Honestly, I can't quite think where it went wrong for you so you'll have to show me what your procedure was.

edit: If I was to take a guess, you added 1 in front of the long expression to get $1+36+36^2+...+36^8$ to get it in the form $1+r+r^2+...+r^n$ in which you then used the formula and plugged in your values as $$\frac{1-36^9}{1-36}$$ and got the higher wrong answer because you forgot to take that 1 you added back out of the value.

Also, an easier way to get it into the form of that formula would be to factorize out 36 so you're then solving $$36(1+36+36^2+...+36^7)=36\cdot \frac{1-36^8}{1-36}$$

Last edited: May 14, 2012
5. May 14, 2012

krytie75

= (1-36^8+1)/(1-36)

= (1-36^9)/(1-36)

= -101559956668415/-35

= 2901713047669

Sorry, I'm new here and don't know how to use the proper maths characters yet.

6. May 14, 2012

Mentallic

Yep, there you go, that's why.

Well you're doing a lot better than many other new guys that come to this forum - you know how to use parenthesis properly!

7. May 14, 2012

krytie75

Ahhh! I forgot my basic maths and didn't balance the equation.

Thanks Mentallic, that's really appreciated.

8. May 15, 2012

Diffy

If the String Can be "" That is a string of length 0 with nothing in it then there are 2,901,713,047,669 possibilities. However you did say that it had to be of at least length one which means that "" is not a valid string combination you want to count.