Skip to content

Commit 794a38f

Browse files
Create ashishfacto.py
1 parent 960872f commit 794a38f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ashishfacto.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python 3 program to find
2+
# factorial of given number
3+
def factorial(n):
4+
if n < 0:
5+
return 0
6+
elif n == 0 or n == 1:
7+
return 1
8+
else:
9+
fact = 1
10+
while(n > 1):
11+
fact *= n
12+
n -= 1
13+
return fact
14+
15+
# Driver Code
16+
num = 5;
17+
print("Factorial of",num,"is",
18+
factorial(num))
19+
20+
# This code is contributed by Dharmik Thakkar

0 commit comments

Comments
 (0)