My issue
Task
Given an integer
π
N, calculate and output the factorial of a
π
N.
Factorial of an integer
π
N is the product of first
π
N natural numbers.
Recursive equation for Factorial:
πΉ
π
π
π‘
π
π
π
π
π
(
π
)
π
β
πΉ
π
π
π‘
π
π
π
π
π
(
π
β
1
)
Factorial(n)=NβFactorial(nβ1),
πΉ
π
π
π‘
π
π
π
π
π
(
0
)
1
Factorial(0)=1,
πΉ
π
π
π‘
π
π
π
π
π
(
1
)
1
Factorial(1)=1
Input Format
Input contains a single integer
π
N
Output Format
Output the Factorial of
π
N
My code
def Factorial(n):
Factorial(n) = N + Factorial(n - 1).Factorial(0) = 1.Factorial(1) = 1
n = int(input())
print(Factorial(n))
Learning course: Design and Analysis of Algorithms
Problem Link: Factorial in Design and Analysis of Algorithms