jeudi 17 septembre 2020

Python Recursion without While loop and find remainder of x/y without using %operators?

Not sure what went wrong, it's not giving output, and I'm thinking of putting "remainder(x-y, y)" in the statement, but still not working.

def remainder(x, y):
  if x == y:
    return 0
  elif x>y:
    x = x-y
    if x<y:
      return x

x=int(input("x: "))
y=int(input("y: "))
print (f'Remainder: {remainder(x, y)}')

Aucun commentaire:

Enregistrer un commentaire