Skip to content

Commit 649f1cd

Browse files
author
devxl
committed
Wrote factorial function...fixed mixed parantheses bug
1 parent 0f001e7 commit 649f1cd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

factorial.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
88

99
def factorial(n):
1010
# TODO Define your logic for factorial here
11-
return # TODO!
11+
fact = 0
12+
if n == 1:
13+
fact = 1
14+
else:
15+
fact = factorial(n-1) * n
16+
return fact # TODO!
17+
1218

1319
def test_factorial():
1420
assert factorial(1) == 1
1521
# TODO: add more
1622

23+
1724
if __name__ == '__main__':
1825
# This is a way to determine either file was "executed", so if it was
1926
# imported (by e.g. pytest) as a library, we should not run code
2027
# below
2128
nconditions = raw_input("Please enter number of conditions: ")
2229
norders = factorial(nconditions)
23-
print("Number of possible trial orders: " + str(norders)
30+
print("Number of possible trial orders: " + str(norders))

0 commit comments

Comments
 (0)