We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 360cc1a commit 8d8c761Copy full SHA for 8d8c761
Code/factorial.py
@@ -0,0 +1,15 @@
1
+#program to find the factorial of a number provided by a user
2
+
3
+if __name__ == "__main__":
4
+ number = int(raw_input("Enter a number to get its factorial: "))
5
+ factorial = 1
6
7
+ if number < 0:
8
+ print("Sorry, factorial doesn't exist for negative numbers!")
9
+ elif number == 0:
10
+ print("The factorial of 0 is 1")
11
+ else:
12
+ for i in range(1, number + 1):
13
+ factorial = factorial * i
14
+ print "The factorial of %r is %r" % (number, factorial)
15
0 commit comments