File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def factorial(number: int) -> int:
3535 return value
3636
3737
38- def factorial_recursive (n : int ) -> int :
38+ def factorial_recursive (num : int ) -> int :
3939 """
4040 Calculate the factorial of a positive integer
4141 https://en.wikipedia.org/wiki/Factorial
@@ -52,17 +52,17 @@ def factorial_recursive(n: int) -> int:
5252 ...
5353 ValueError: factorial() not defined for negative values
5454 """
55- if not isinstance (n , int ):
55+ if not isinstance (num , int ):
5656 raise ValueError ("factorial() only accepts integral values" )
57- if n < 0 :
57+ if num < 0 :
5858 raise ValueError ("factorial() not defined for negative values" )
59- return 1 if n in {0 , 1 } else n * factorial_recursive (n - 1 )
59+ return 1 if num in {0 , 1 } else num * factorial_recursive (num - 1 )
6060
6161
6262if __name__ == "__main__" :
6363 import doctest
6464
6565 doctest .testmod ()
6666
67- n = int (input ("Enter a positive integer: " ).strip () or 0 )
68- print (f"factorial{ n } is { factorial (n )} " )
67+ num = int (input ("Enter a positive integer: " ).strip () or 0 )
68+ print (f"factorial{ n } is { factorial (num )} " )
You can’t perform that action at this time.
0 commit comments