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 992bd3d commit a85275fCopy full SHA for a85275f
project_euler/problem_03/sol3.py
@@ -7,7 +7,7 @@
7
"""
8
9
10
-def solution(n: int) -> int:
+def solution(n: int = 600851475143) -> int:
11
"""Returns the largest prime factor of a given number n.
12
13
>>> solution(13195)
@@ -41,23 +41,26 @@ def solution(n: int) -> int:
41
raise TypeError("Parameter n must be int or passive of cast to int.")
42
if n <= 0:
43
raise ValueError("Parameter n must be greater or equal to one.")
44
+
45
i = 2
46
ans = 0
47
48
if n == 2:
49
return 2
50
51
while n > 2:
52
while n % i != 0:
53
i += 1
54
55
ans = i
56
57
while n % i == 0:
58
n = n / i
59
60
61
62
return int(ans)
63
64
65
if __name__ == "__main__":
- # print(solution(int(input().strip())))
- import doctest
-
- doctest.testmod()
66
+ print(solution(int(input().strip())))
0 commit comments