title: Recursive formula in python for recursive sigma how to?
body: <p>I recently asked <a href="https://math.stackexchange.com/questions/307906/ways-to-add-up-10-numbers-between-1-and-12-to-get-70-where-order-is-unimportant/307928#307928">this</a> question and got the first answer. I'm trying to put this into python code. This is what I have, but I keep getting 0 as the answer.</p>
  
  <pre><code>def f(n, k, s):
      ans = 0
      for j in range(1, min({k,s}) + 1):
          print j
          if (n == 1):
              if (k &gt;= s):
                  ans = ans + 1
              elif (k &lt; s):
                  ans = ans + 0
              elif (s &gt; n):
                  ans = ans + 0
          elif (n*k &lt; s):
              ans = ans + 0
          else:
              ans = ans + f(n-1,j,s-j)
      return ans
  
  print f(10, 12, 70)
  </code></pre>
  
  <p>What is wrong with my code? What do I need to change? I don't know what's wrong. Please help. Thanks!</p>