二手产品经理

二手产品经理

THIS IS RENO

Recursion - 57 days - Learn Python online for 100 days.

Notes#

  1. Today, I learned about recursion. Recursion means calling oneself. Generally, it refers to the part in a function where it calls itself.
  2. This concept is quite challenging and requires more practice.
  3. Today's coding exercise is to write a factorial function.

CODE#

print("What Is Recursion?")


def reverse(value):
  if value <= 0:
    print("DONE!")
    return 1
  else:
    factorial = value * reverse(value - 1)
    return factorial


num = int(input("NUM ? > "))
print(reverse(num))

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.