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.
  • There are Num guys
  • The sum of their ages is Tot
  • The Age of every one of them is Min <= Age <= Max

I want to create a formula for a program to calculate the total number of possibilities

Any ideas/links that point me to the right direction are appreciated

share|improve this question
    
What you are asking seems to be about partitions of a number, and more specifically partitions of Tot - Num*Min with at most Num summands and no summand greater than Max - Min. Formulas for this kind of thing can be pretty hard to program, but setting up a loop to run through all of the possibilities and count them is pretty straightforward. See Henry Bottomley's online partition calculators for some ideas. –  hardmath Apr 23 '12 at 18:22
    
@BrettFrankel sorry, I wasn't familiarized with any tags, but after some time reading I think I found some that fit ^^ –  ajax333221 Apr 23 '12 at 18:58
    
@ajax333221: Those tags were inapproriate -- I replaced them with combinatorics. –  joriki Apr 23 '12 at 19:25

1 Answer 1

up vote 2 down vote accepted

You can map this to the problem of balls in bins with limited capacity by subtracting $\text{Num}\cdot\text{Min}$ from $\text{Tot}$ and then distributing the remainder into $\text{Num}$ bins with equal capacity $\text{Max}-\text{Min}$. The above page gives a formula for the case of equal capacities at the very end, which can be derived using the inclusion–exclusion principle by considering the number of bins filled to capacity.

share|improve this answer

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.