 # Python basic function

write an iterative function that takes two parameters and uses repeated subtraction to return the value of a%b

What have you tried, what are you stuck on, what do you not understand?

You mean recursive function…?

I dont understand how to do it

yes i guess a recursive

to subtract what inside the recursive function? Its little confusing

Right but I don’t know what you know. I don’t know if you know any basic python, I don’t know if you know any basic maths, if you understand what they’re asking you

• do you understand what modulo is, eg what the answer to `4 mod 2` or to `6 mod 4` is? (Python uses the % symbol for modulo - eg `4 % 2`)
• do you understand how it is related to repeated subtraction?
• do you understand how to declare, assign and update a variable?
• do you understand how to write a loop?

I know all of that , i just don’t understand how to relate it to subtraction
I know basic python !

So

``````10 mod 3
``````

Is 1.

I can get that valie by subtracting 3 from 10, then 3 from the remainder of that and so on over and over until a specific condition is met.

It is a recursive function.