1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Another how many combinations question - slightly more complicated

  1. May 13, 2012 #1
    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?

    Thanks in advance!
  2. jcsd
  3. May 13, 2012 #2


    User Avatar
    Homework Helper

    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

    And just as a reminder, we can evaluate this more simply by using the formula [tex]1+r+r^2+...+r^n=\frac{1-r^{n+1}}{1-r}[/tex]
  4. May 14, 2012 #3
    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:


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


    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!
  5. May 14, 2012 #4


    User Avatar
    Homework Helper

    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 [itex]1+36+36^2+...+36^8[/itex] to get it in the form [itex]1+r+r^2+...+r^n[/itex] in which you then used the formula and plugged in your values as [tex]\frac{1-36^9}{1-36}[/tex] 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 [tex]36(1+36+36^2+...+36^7)=36\cdot \frac{1-36^8}{1-36}[/tex] :wink:
    Last edited: May 14, 2012
  6. May 14, 2012 #5
    = (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.
  7. May 14, 2012 #6


    User Avatar
    Homework Helper

    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!
  8. May 14, 2012 #7
    Ahhh! I forgot my basic maths and didn't balance the equation.

    Thanks Mentallic, that's really appreciated.
  9. May 15, 2012 #8
    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.
    Thus 2,901,713,047,668 would be your correct answer.

    Just thought I would add some context to the 1 difference you were seeing between the formulas.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook