Results 1 to 7 of 7

Thread: OK, another maths question

  1. #1

    Default OK, another maths question

    if I have a set of n numbers and these numbers could be added together in combinations of up to m (allowing for duplications) how would I find all the possible combinations?

    So say n {1,2} and m were 2 then I could have combinations that came to: 1,2,3,4.

    1 from 1
    2 from 1+1 or 2
    3 from 1+2
    4 from 2+2

    However, I need to be able to do this for potentially any set of n and up to any m.

    anybody got relevant algorithms floating around?

    cheers,

    Taffy

    P.S.

  2. #2
    The Black Senior Member Papewaio's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    15,677

    Default Re: OK, another maths question

    Factorials. 2n!
    Our genes maybe in the basement but it does not stop us chosing our point of view from the top.
    Quote Originally Posted by Louis VI the Fat
    Pape for global overlord!!
    Quote Originally Posted by English assassin
    Squid sources report that scientists taste "sort of like chicken"
    Quote Originally Posted by frogbeastegg View Post
    The rest is either as average as advertised or, in the case of the missionary, disappointing.

  3. #3
    Vermonter and Seperatist Member Uesugi Kenshin's Avatar
    Join Date
    Nov 2004
    Location
    The Mountains.
    Posts
    3,868

    Default Re: OK, another maths question

    I was thinking he was talking about factorials, but for some reason it didn't seem quite the same....They seem to be a bit different, it looks to me like he wants a formula to come up with the set of all numbers that can be formed by adding a set of numbers together in different ways.

    Factorials are multiplication, like 6! is 6x5x4x3x2x1 right?

    I haven't done this in a while though, and haven't gotten to any algorithms yet so I could be wrong.
    "A man's dying is more his survivor's affair than his own."
    C.S. Lewis

    "So many people tiptoe through life, so carefully, to arrive, safely, at death."
    Jermaine Evans

  4. #4
    Master of useless knowledge Senior Member Kitten Shooting Champion, Eskiv Champion Ironside's Avatar
    Join Date
    Sep 2003
    Location
    Sweden
    Posts
    4,902

    Default Re: OK, another maths question

    n^m covers the additions of numbers (I think, more based on memory than actual calculation) but not the lower m combinations (AKA m=3, then it doesn't cover the numbers for m=2,1). So I'm guessing n^m would work.

    Problem is that to cover all numbers you'll need n^m+n^(m-1) + ... + n^1.

    Should be a better way to combine that.
    We are all aware that the senses can be deceived, the eyes fooled. But how can we be sure our senses are not being deceived at any particular time, or even all the time? Might I just be a brain in a tank somewhere, tricked all my life into believing in the events of this world by some insane computer? And does my life gain or lose meaning based on my reaction to such solipsism?

    Project PYRRHO, Specimen 46, Vat 7
    Activity Recorded M.Y. 2302.22467
    TERMINATION OF SPECIMEN ADVISED

  5. #5
    Member Member Narayanese's Avatar
    Join Date
    Mar 2005
    Location
    Stockholm
    Posts
    398

    Default Re: OK, another maths question

    If I understand the problem correctly, the answer is all numbers from 1 to m*n, because if one sum is possible then the sum one smaller is possible too because you can always chose a number in a term one smaller, and the largest sum possible is having all the m terms equal to n.

  6. #6
    Thread killer Member Rodion Romanovich's Avatar
    Join Date
    Mar 2005
    Location
    The dark side
    Posts
    5,383

    Default Re: OK, another maths question

    IIRC it's an NP complete problem. You have to test all possibilities to find the solution. Some clever tricks can make it slightly faster, but it's basically about testing all combinations.
    Last edited by Rodion Romanovich; 02-12-2006 at 22:31.
    Under construction...

    "In countries like Iran, Saudi Arabia and Norway, there is no separation of church and state." - HoreTore

  7. #7
    Master of useless knowledge Senior Member Kitten Shooting Champion, Eskiv Champion Ironside's Avatar
    Join Date
    Sep 2003
    Location
    Sweden
    Posts
    4,902

    Default Re: OK, another maths question

    My basic formula was a bit too number counting, it includes all combinations, even though 1+1+2, 1+2+1, 2+1+1 could be treated as the same.
    We are all aware that the senses can be deceived, the eyes fooled. But how can we be sure our senses are not being deceived at any particular time, or even all the time? Might I just be a brain in a tank somewhere, tricked all my life into believing in the events of this world by some insane computer? And does my life gain or lose meaning based on my reaction to such solipsism?

    Project PYRRHO, Specimen 46, Vat 7
    Activity Recorded M.Y. 2302.22467
    TERMINATION OF SPECIMEN ADVISED

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO