Skip to content

Commit a0cb2d9

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

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

factorial.py

Lines changed: 10 additions & 3 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
21-
nconditions = raw_input("Please enter number of conditions: ")
28+
nconditions = 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)