Skip to content

Commit 1aa76d0

Browse files
Merge pull request #3 from twilight-debugger/twilight-debugger-patch-3
Rename parameter in factorial_recursive function
2 parents bc49692 + a75c1c8 commit 1aa76d0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

maths/factorial.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff 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

6262
if __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)}")

0 commit comments

Comments
 (0)