Skip to content

Commit e1523a7

Browse files
author
Mohsen Rakhshan
committed
remove unnecessary if condition
1 parent c5d23b7 commit e1523a7

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

factorial.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@
88

99
def factorial(n):
1010

11-
if n == 0 or n < 0:
11+
outputCalc = 1
1212

13-
outputCalc = 1
13+
for number in range(1, n+1):
1414

15-
else:
16-
17-
outputCalc = 1
18-
19-
for number in range(1, n+1):
20-
21-
outputCalc = number * outputCalc
15+
outputCalc = number * outputCalc
2216

2317
return outputCalc
2418

2519

2620
def test_factorial():
27-
assert factorial(1) == 1
21+
assert factorial(2) == 1
2822
assert factorial(0) == 1
2923
assert factorial(-10) == 1
3024

0 commit comments

Comments
 (0)