File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 7
7
"""
8
8
9
9
10
- def solution (n : int ) -> int :
10
+ def solution (n : int = 600851475143 ) -> int :
11
11
"""Returns the largest prime factor of a given number n.
12
12
13
13
>>> solution(13195)
@@ -41,23 +41,26 @@ def solution(n: int) -> int:
41
41
raise TypeError ("Parameter n must be int or passive of cast to int." )
42
42
if n <= 0 :
43
43
raise ValueError ("Parameter n must be greater or equal to one." )
44
+
44
45
i = 2
45
46
ans = 0
47
+
46
48
if n == 2 :
47
49
return 2
50
+
48
51
while n > 2 :
49
52
while n % i != 0 :
50
53
i += 1
54
+
51
55
ans = i
56
+
52
57
while n % i == 0 :
53
58
n = n / i
59
+
54
60
i += 1
55
61
56
62
return int (ans )
57
63
58
64
59
65
if __name__ == "__main__" :
60
- # print(solution(int(input().strip())))
61
- import doctest
62
-
63
- doctest .testmod ()
66
+ print (solution (int (input ().strip ())))
You can’t perform that action at this time.
0 commit comments