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 18f9426 commit f63d74bCopy full SHA for f63d74b
exercises/020-factorial/solution.hide.py
@@ -1,17 +1,17 @@
1
-def fact(x):
2
- if x == 0:
3
- return 1
4
- return x * fact(x - 1)
5
-
6
-x=int(input())
7
-print (fact(x))
8
+# Your code here
+def factorial(x):
+ result = 1
+ for i in range(1, x + 1):
+ result *= i
+ return result
9
10
-# or
+print(factorial(5))
11
12
-# Your code here
13
-import math
14
-def factorial(num):
15
- return math.factorial(num)
+### Solution 2 ###
16
17
-print(factorial(8))
+# import math
+#
+# def factorial(x):
+# return math.factorial(x)
+# print(factorial(8))
0 commit comments