Python: writing function mult(a,b) for a*b with only add/sub/neg, recursion error for testing (-a,b)
<p>I have this so far - but if I test with (-a, b), python gives me a recursion error. Please help, not sure why this isn't working. All other tests work here.</p>

<pre><code>def mult(a, b):
""" mult returns the product of two inputs
    inputs: n and m are integers
    output: result of multiplying n and m
""" 
    if b &lt; 0:
       return -mult(a,-b)
    elif b == 0:
       return 0
    elif b == 1:
       return a
    else:
       return a + mult(a,b-1)
</code></pre>

<p>Thanks out there. </p>

<p>Python has a limit to the number of recursions. You may just be hitting into it. See the following answer:</p>

<p><a href="http://stackoverflow.com/questions/3323001/maximum-recursion-depth">Maximum recursion depth?</a></p>

python function python-3.x recursion multiplication