title: i have a list of numbers and a certain sum, and i need to calculate the possible number of ways to generate that sum
body: <p>Also, repetition of numbers is allowed.</p>
  
  <p>I reffered to the program:</p>
  
  <pre><code>def subset_sum_recursive(numbers,target,partial):
      s = sum(partial)
  
      #check if the partial sum is equals to target
      if s == target: 
          print "sum(%s)=%s"%(partial,target)
      if s &gt;= target:
          return # if we reach the number why bother to continue
  
      for i in range(len(numbers)):
          n = numbers[i]
          remaining = numbers[i+1:]
          subset_sum_recursive(remaining,target,partial + [n]) 
  
  def subset_sum(numbers,target):
      #we need an intermediate function to start the recursion.
      #the recursion start with an empty list as partial solution.
      subset_sum_recursive(numbers,target,list())
  
  if __name__ == "__main__":
      subset_sum([3,9,8,4,5,7,10],15)
  
      #Outputs:
      #sum([3, 8, 4])=15
      #sum([3, 5, 7])=15
      #sum([8, 7])=15
      #sum([5, 10])=15
  </code></pre>
  
  <p>but i am not getting where to put the count variable , its so confusing</p>