Skip to content

Commit a85275f

Browse files
committed
Add default arg for 3rd soln of PE TheAlgorithms#3
1 parent 992bd3d commit a85275f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: project_euler/problem_03/sol3.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99

10-
def solution(n: int) -> int:
10+
def solution(n: int = 600851475143) -> int:
1111
"""Returns the largest prime factor of a given number n.
1212
1313
>>> solution(13195)
@@ -41,23 +41,26 @@ def solution(n: int) -> int:
4141
raise TypeError("Parameter n must be int or passive of cast to int.")
4242
if n <= 0:
4343
raise ValueError("Parameter n must be greater or equal to one.")
44+
4445
i = 2
4546
ans = 0
47+
4648
if n == 2:
4749
return 2
50+
4851
while n > 2:
4952
while n % i != 0:
5053
i += 1
54+
5155
ans = i
56+
5257
while n % i == 0:
5358
n = n / i
59+
5460
i += 1
5561

5662
return int(ans)
5763

5864

5965
if __name__ == "__main__":
60-
# print(solution(int(input().strip())))
61-
import doctest
62-
63-
doctest.testmod()
66+
print(solution(int(input().strip())))

0 commit comments

Comments
 (0)