Modulo operation recursive
<p>To practice a little bit recursion I tried to rewrite the <code>modulo</code> function in python recursive. 
<code>20%6</code> yields <code>2</code>.</p>

<p>I tried to approach it the following way: add <code>m</code> to itself so often until it becomes bigger than <code>a</code>. If so, subtract <code>a-m</code> and return that value.</p>

<pre><code>def mod1(a,m):
    if m == a:
        return 0
    elif m &lt; a:
        return mod1(a,m+m)
    else: 
        return a - m

mod(20,6)
&gt; -4
</code></pre>

<p>However, the problem I am having is that the <code>m</code> I add on <code>m</code> changes. In the first step of the recursion it is <code>6+6</code>, in the second iteration instead of <code>12+6</code> it is <code>12+12</code>. 
How to "keep" my original <code>m</code>, but updating the one I need to change? </p>