title: Adding values in various combinations
body: <p>Not sure how best to explain it, other than using an example...</p>
  
  <p>Imagine having a client with 10 outstanding invoices, and one day they provide you with a cheque, but do not tell you which invoices it's for.</p>
  
  <p>What would be the best way to return all the possible combination of values which can produce the required total?</p>
  
  <hr>
  
  <p>My current thinking is a kind of brute force method, which involves using a self-calling function that runs though all the possibilities (<a href="http://www.craigfrancis.co.uk/features/code/phpAddition/" rel="nofollow noreferrer">see current version</a>).</p>
  
  <p>For example, with 3 numbers, there are 15 ways to add them together:</p>
  
  <ol>
  <li>A</li>
  <li>A + B</li>
  <li>A + B + C</li>
  <li>A + C</li>
  <li>A + C + B</li>
  <li>B</li>
  <li>B + A</li>
  <li>B + A + C</li>
  <li>B + C</li>
  <li>B + C + A</li>
  <li>C</li>
  <li>C + A</li>
  <li>C + A + B</li>
  <li>C + B</li>
  <li>C + B + A</li>
  </ol>
  
  <p>Which, if you remove the duplicates, give you 7 unique ways to add them together:</p>
  
  <ol>
  <li>A</li>
  <li>A + B</li>
  <li>A + B + C</li>
  <li>A + C</li>
  <li>B</li>
  <li>B + C</li>
  <li>C</li>
  </ol>
  
  <p>However, this kind of falls apart after you have:</p>
  
  <ul>
  <li>15 numbers (32,767 possibilities / ~2 seconds to calculate)</li>
  <li>16 numbers (65,535 possibilities / ~6 seconds to calculate)</li>
  <li>17 numbers (131,071 possibilities / ~9 seconds to calculate)</li>
  <li>18 numbers (262,143 possibilities / ~20 seconds to calculate)</li>
  </ul>
  
  <p>Where, I would like this function to handle at least 100 numbers.</p>
  
  <p>So, any ideas on how to improve it? (in any language)</p>