title: Finding the number of different combinations of numbers such that its total equals to sum
body: <p>I would like to find out the number of different combinations of non-negative numbers(can be any number, it is not fixed) such that its total equals to the sum that is provided.</p>
  
  <p>for example : I have 3 numbers and i want to find the different combinations of numbers such that the sum is 4. the value of num starts from 0. no negative numbers.</p>
  
  <p>For 3 numbers that sum to 4, the combinations are </p>
  
  <pre><code>2 0 2
  2 2 0
  0 2 2
  0 1 3
  3 1 0
  0 3 1 
  1 0 3
  1 3 0
  3 0 1
  0 0 4
  4 0 0
  0 4 0
  2 1 1
  1 2 1
  1 1 2
  </code></pre>
  
  <p>I saw this as an example : <a href="https://stackoverflow.com/questions/8871180/finding-the-total-number-combinations-for-an-integer-using-three-numbers">Finding the total number combinations for an integer using three numbers</a></p>
  
  <p>But the problem is it only uses three numbers. </p>
  
  <p>Any algorithm or code will be useful. Thanks.</p>