Creating a recursive function for calculating R = x - N * y, with conditions
<p>I wish to create a function for calculating R = x - N * y, where x and y are floats and N is the largest positive integer, so that x > N * y.</p>

<p>The function should only take the inputs of x and y.</p>

<p>I have previously created the function through a loop, but having trouble trying to convert it to recursion. My basic idea is something like:</p>

<pre><code>def florec(x, y):
    if x &gt; y:
        R = x - N * y
        florec(x, y_increased)
    return R
</code></pre>

<p>My problem is that I can not figure out how to code "y_increased", meaning, how I can update N to N+1, and then call upon florec(x, (N+1)*y). Then update N+1 to N+2 and call upon florec(x, (N+2)*y) and so on.</p>

<p>Feeling quite stuck currently, so any help at all to move forward would be appreciated.</p>

<p>Here's a recursive way of computing R:</p>

<pre><code>def florec(x, y):
    if x &gt; y:
        return florec(x-y, y)
    return x
</code></pre>

<p>(Note it only works for positive floats.)</p>

<p>I don't know if this addresses your recursion issues. Maybe this use case is not best suited to illustrate recursion.</p>

python python-3.x