Python Recursiveness - Rest of the division of two numbers

Asked

Viewed 164 times

-3

I’m having trouble solving a problem in Python using recursive form:

Make a recursive function that gets the rest of the split between two positive integers. Example: rest(33,5) = 3

Can you please help me? I only know how to solve the statement in question, in the traditional way

Thanks in advance!

  • Could edit the question and put a [mcve] showing your attempt to solve the problem.

1 answer

1


A solution:

def resto(n, m):
    if (n < m):
        return (n)
    else:
        return resto(n-m, m)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.