title: What is the most efficient way to get all combinations?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4632322/finding-all-possible-combinations-of-numbers-to-reach-a-given-sum">Finding all possible combinations of numbers to reach a given sum</a>  </p>
  </blockquote>
  
  
  
  <p><strong>Problem</strong></p>
  
  <p>You have a list of people as input, each person has a number of credits. You are given a total that has to be achieved by using one or more persons credits. The function should output all combinations that exist that will result in the total.</p>
  
  <p>For example see below:-</p>
  
  <pre><code>static void Main(string[] args)
  {
      int total = Convert.ToInt32(args[0]);
      var persons = new List&lt;Person&gt;();
      persons.Add(new Person { Credits = 10, Name="Steve"});
      persons.Add(new Person { Credits = 5, Name = "Paul" });
      persons.Add(new Person { Credits = 4, Name = "David" });
      persons.Add(new Person { Credits = 1, Name = "Kenneth" });
  
      PrintAllCombinations(persons, total); // The function in question
  }
  public class Person
  {
      public string Name { get; set; }
      public int Credits { get; set; }
  }
  </code></pre>
  
  <p>In the above example, given a total of 10, the PrintAllCombinations function should output something similar to:-</p>
  
  <ul>
  <li>Combination 1) Steve:10</li>
  <li>Combination 2) Paul: 5, David 4, Kenneth 1</li>
  <li>Combination 3) Steve: 9, Paul 1</li>
  <li>Combination 4) Steve: 5, Paul 5</li>
  <li>...etc</li>
  </ul>
  
  <p><strong>UPDATE: I forgot to mention, you can use any part of a persons credits</strong> </p>
  
  <p>The example I used is simplified, but the real scenario would be constrained to having no more than a 100 people and the total will always be less than 90.</p>
  
  <p>What is the best solution?</p>