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 0f001e7 commit 649f1cdCopy full SHA for 649f1cd
factorial.py
@@ -8,16 +8,23 @@
8
9
def factorial(n):
10
# TODO Define your logic for factorial here
11
- return # TODO!
+ fact = 0
12
+ if n == 1:
13
+ fact = 1
14
+ else:
15
+ fact = factorial(n-1) * n
16
+ return fact # TODO!
17
+
18
19
def test_factorial():
20
assert factorial(1) == 1
21
# TODO: add more
22
23
24
if __name__ == '__main__':
25
# This is a way to determine either file was "executed", so if it was
26
# imported (by e.g. pytest) as a library, we should not run code
27
# below
28
nconditions = raw_input("Please enter number of conditions: ")
29
norders = factorial(nconditions)
- print("Number of possible trial orders: " + str(norders)
30
+ print("Number of possible trial orders: " + str(norders))
0 commit comments