Skip to content

Commit 5d0aae2

Browse files
committed
Added wrapper function for factors_recursion() to prevent taking incorrect optional parameters reserved for recursion
Consequently made factors_recursion() private
1 parent ce13b73 commit 5d0aae2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

factors.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ def factors_iteration(number: int, use_while: bool = False) -> list[int]:
2929
return factors
3030

3131
@staticmethod
32-
def factors_recursion(number: int, next_factor: Optional[int] = None, factors: Optional[list[int]] = None,
33-
negative_factors: bool = False) -> list[int]:
32+
def factors_recursion(number: int) -> list[int]:
33+
return Factors.__factors_recursion_implementation(number)
34+
35+
@staticmethod
36+
def __factors_recursion_implementation(number: int, next_factor: Optional[int] = None,
37+
factors: Optional[list[int]] = None,
38+
negative_factors: bool = False) -> list[int]:
3439
if next_factor is None and factors is None:
3540
factors = []
3641
next_factor = abs(number)
@@ -46,7 +51,7 @@ def factors_recursion(number: int, next_factor: Optional[int] = None, factors: O
4651
if negative_factors:
4752
factors.append(-1 * next_factor)
4853
factors.append(next_factor)
49-
return Factors.factors_recursion(number, next_factor - 1, factors, negative_factors)
54+
return Factors.__factors_recursion_implementation(number, next_factor - 1, factors, negative_factors)
5055

5156

5257
if __name__ == '__main__':

0 commit comments

Comments
 (0)