-
Notifications
You must be signed in to change notification settings - Fork 1
/
Recursion3HR.py
39 lines (28 loc) · 902 Bytes
/
Recursion3HR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Objective
Today, we're learning and practicing an algorithmic concept called Recursion. Check out the Tutorial tab for learning materials and an instructional video!
Recursive Method for Calculating Factorial
Task
Write a factorial function that takes a positive integer, as a parameter and prints the result of ( factorial).
Note: If you fail to use recursion or fail to name your recursive function factorial or Factorial, you will get a score of .
Input Format
A single integer, (the argument to pass to factorial).
Constraints
Your submission must contain a recursive function named factorial.
Output Format
Print a single integer denoting .
Sample Input
3
Sample Output
6
"""
# SOLUTION
# Complete the factorial function below.
def factorial(n):
if n == 1 :
return 1
else :
return n*factorial(n-1)
n = int(input())
result = factorial(n)
print(result)