Skip to content

Commit 602c1d6

Browse files
committed
factorail using reduce
1 parent f92a8ff commit 602c1d6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

maths/factorial.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def factorial(number: int) -> int:
3131
raise ValueError("factorial() only accepts integral values")
3232
if number < 0:
3333
raise ValueError("factorial() not defined for negative values")
34-
if number in {0, 1}: return 1
35-
value = reduce(lambda x , y: x * y, range(1, number + 1))
34+
value = 1 if number in {0, 1} else reduce(lambda x , y: x * y, range(1, number + 1))
3635
return value
3736

3837

0 commit comments

Comments
 (0)