Skip to content

Commit 72e3554

Browse files
Merge pull request #27 from ghanshyam1898/factorial_feature
Adds the factorial feature
2 parents 7691d43 + fdfe6e3 commit 72e3554

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Code/factorial.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def get_factorial(number):
2+
answer = 1 # We start with 1 as usual for finding factorial
3+
4+
for i in range(1, (number+1)): # 1 is added to second argument of range function since it in this syntax loop terminates at the second value without executing for that value.
5+
answer = answer * i
6+
7+
return answer # answer now contains the calculated value
8+
9+
10+
11+
if __name__ == '__main__':
12+
number = input("Enter the number : ")
13+
number = int(number)
14+
factorial = get_factorial(number)
15+
print ("The factorial of " + number+ " is = " + factorial)
16+

0 commit comments

Comments
 (0)