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 e40c358 commit 3333d9bCopy full SHA for 3333d9b
source/recursion.py
@@ -4,7 +4,7 @@ def factorial(n):
4
"""factorial(n) returns the product of the integers 1 through n for n >= 0,
5
otherwise raises ValueError for n < 0 or non-integer n"""
6
# check if n is negative or not an integer (invalid input)
7
- if n < 0 or not isinstance(n, int):
+ if not isinstance(n, int) or n < 0:
8
raise ValueError('factorial is undefined for n = {}'.format(n))
9
# implement factorial_iterative and factorial_recursive below, then
10
# change this to call your implementation to verify it passes all tests
0 commit comments