RECURSION (RECURSIVE FUNCTION)

 TASK:    To display the factorial of a number entered by the user.

CODE:

def factorial(n):
    if n==1:
        return 1
    else:
        return n*factorial(n-1)
num=int(input())
print(factorial(num))

LOGIC:




Comments

Popular posts from this blog

LOOP, STRING, LIST, CONDITION

CLASS AND OBJECT

LIST INPUT FROM USER