Results 1 to 13 of 13

Math Help - Combinations of digits - formula needed.

  1. #1
    Newbie
    Joined
    Sep 2010
    Posts
    5

    Question Combinations of digits - formula needed.

    Hi there,

    Lets look at this little problem...

    - Given the integer number 123, combining its digits in all possible positions, the results are:
    123, 132, 213, 231, 312, 321
    ... a total of 6 combinations.

    - Doing the same with number 1234, the results are:
    1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431,
    3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321
    ... a total of 24 combinations.

    So, my question is: what formula can I use to get the total number of combinations, given L as the digits length?



    Thanks
    Last edited by mr fantastic; September 13th 2010 at 01:36 PM. Reason: Re-titled.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member yeKciM's Avatar
    Joined
    Jul 2010
    Posts
    456
    Quote Originally Posted by Betty View Post
    Hi there,

    Lets look at this little problem...

    - Given the integer number 123, combining its digits in all possible positions, the results are:
    123, 132, 213, 231, 312, 321
    ... a total of 6 combinations.

    - Doing the same with number 1234, the results are:
    1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431,
    3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321
    ... a total of 24 combinations.

    So, my question is: what formula can I use to get the total number of combinations, given L as the digits length?



    Thanks


    it's n factorial

     n!= n \cdot (n-1)\cdot (n-2) \cdot ...

    so n=6

     6! = 6\cdot 5\cdot 4 \cdot 3 \cdot 2\cdot 1 =  720
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Betty View Post
    Hi there,

    Lets look at this little problem...

    - Given the integer number 123, combining its digits in all possible positions, the results are:
    123, 132, 213, 231, 312, 321
    ... a total of 6 combinations.

    - Doing the same with number 1234, the results are:
    1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431,
    3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321
    ... a total of 24 combinations.

    So, my question is: what formula can I use to get the total number of combinations, given L as the digits length?



    Thanks
    Are all the digits different?

    CB
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Sep 2010
    Posts
    5

    Red face

    Thanks!

    It was easy, and I forgot
    The little "!" is a killer, indeed.

    I'm using it on a programming function. Amazing, it seams no native support for it in several languages, so we need to go with a recursive function or a loop, as I did (VB.NET):

    Private Function Factorial(ByVal length As Integer) As Integer
    Dim res As Integer = 1
    For i = 1 To length
    res *= i
    Next
    Return res
    End Function


    Are all the digits different?
    No. The same digit can repeat.

    Actually, the digits are not digits, are letters, but for the purposes of my application, all computations are done numerically, and not in string or char data types, for obvious efficiency.

    Kind regards,
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Senior Member yeKciM's Avatar
    Joined
    Jul 2010
    Posts
    456
    Quote Originally Posted by Betty View Post

    No. The same digit can repeat.

    Kind regards,

    if they can repeat than just n! can't do you any help

    that's in the case that they can't repeat ... as you wrote there for 1,2,3

    Quote Originally Posted by Betty View Post
    123, 132, 213, 231, 312, 321
    than is not included 111 and such ....
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Member
    Joined
    Sep 2010
    Posts
    185
    Thanks
    13
    Quote Originally Posted by Betty View Post
    ...

    No. The same digit can repeat.

    Actually, the digits are not digits, are letters, but for the purposes of my application, all computations are done numerically, and not in string or char data types, for obvious efficiency.

    Kind regards,
    Then factorials just don't cut it.

    If you can use any letter any number of times then using your example, if you have 4 different letters that you can repeatedly use to use to compose a 4 letter "word" (sequence of letters), then there are 4^4 different words you can put together.

    n different symbols that you can repeat can form n^k diferent sequences of length k.
    on every 'place' in the sequence of length k, you can always choose any of n available 'symbols'.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Sep 2010
    Posts
    5
    if they can repeat than just n! can't do you any help
    Oh, I guess I wasn't clear.

    The digits can repeat, but can not change.

    By repeat I mean "1434"... there are two 4 digits.

    But given "1434", the digits can not change to anything they aren't, such as "1444"... because there weren't three 4's in the first place.

    This is a permutation of digits. Restricted to the original digits (that are not all necessarly different, such as "1234", can be also "1434"
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Senior Member yeKciM's Avatar
    Joined
    Jul 2010
    Posts
    456
    Quote Originally Posted by Betty View Post
    Oh, I guess I wasn't clear.

    The digits can repeat, but can not change.

    By repeat I mean "1434"... there are two 4 digits.

    But given "1434", the digits can not change to anything they aren't, such as "1444"... because there weren't three 4's in the first place.

    This is a permutation of digits. Restricted to the original digits (that are not all necessarly different, such as "1234", can be also "1434"
    than is okay
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Sep 2010
    Posts
    5
    than is okay
    Yes, the factorial is the answer for permutations.

    Thank's again, guys!

    By the way, someone mentioned the word "word"... so here it goes the permutations:

    word, wodr, wrod, wrdo, wdor, wdro, owrd, owdr, orwd, ordw, odwr, odrw,
    rwod, rwdo, rowd, rodw, rdwo, rdow, dwor, dwro, dowr, dorw, drwo, drow

    4!
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Betty View Post
    Yes, the factorial is the answer for permutations.

    Thank's again, guys!

    By the way, someone mentioned the word "word"... so here it goes the permutations:

    word, wodr, wrod, wrdo, wdor, wdro, owrd, owdr, orwd, ordw, odwr, odrw,
    rwod, rwdo, rowd, rodw, rdwo, rdow, dwor, dwro, dowr, dorw, drwo, drow

    4!
    You know that with repeated charaters that the answer given is wrong, it assumes they are all distinguishable.

    That is you treat 1434 as different from 1434.

    CB
    Follow Math Help Forum on Facebook and Google+

  11. #11
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Where there are repeated characters you can use the multinomial coefficient

    Multinomial Coefficient -- from Wolfram MathWorld

    For example, "excellent" there are 3 E's, 1 X, 1 C, 2 L's, 1 N, and 1 T, giving

    (3,1,1,2,1,1)! = \dfrac{(3+1+1+2+1+1)!}{(3!)^1(2!)^1(1!)^4}
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Newbie
    Joined
    Sep 2010
    Posts
    5
    You know that with repeated charaters that the answer given is wrong, it assumes they are all distinguishable.
    Good point, thanks. For the purpose of my word anagram application, I sure can't tell "alma" is distinguishable from "alma". They are the same, so I shouldn't count them twice as if different, like the factorial n! does.

    you can use the multinomial coefficient
    Thanks. I better implement that function in code, instead of factorial.
    Follow Math Help Forum on Facebook and Google+

  13. #13
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Quote Originally Posted by Betty View Post
    Amazing, it seams no native support for it in several languages
    I think there is a good reason for this; at 13! you overflow 32-bit ints, and at 21! you overflow 64-bit ints.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 8
    Last Post: September 27th 2010, 07:09 PM
  2. Help needed on sum of product combinations
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: March 4th 2009, 06:40 AM
  3. Replies: 0
    Last Post: February 27th 2009, 08:04 AM
  4. Replies: 3
    Last Post: February 5th 2009, 11:56 AM
  5. Formula for a game of combinations of numbers...
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: October 28th 2008, 07:37 AM

Search Tags


/mathhelpforum @mathhelpforum