@@ -47,18 +47,18 @@ def sum_primes(primes_degrees: dict[int, int], num: int) -> int:
47
47
)
48
48
49
49
50
- def generate_primes (max_num : int ) -> list [int ]:
50
+ def generate_primes (max_prime : int ) -> list [int ]:
51
51
"""
52
- Calculates the list of primes up to and including `max_num `.
52
+ Calculates the list of primes up to and including `max_prime `.
53
53
54
54
>>> generate_primes(6)
55
55
[2, 3, 5]
56
56
"""
57
- are_primes = [True ] * (max_num + 1 )
57
+ are_primes = [True ] * (max_prime + 1 )
58
58
are_primes [0 ] = are_primes [1 ] = False
59
- for i in range (2 , isqrt (max_num ) + 1 ):
59
+ for i in range (2 , isqrt (max_prime ) + 1 ):
60
60
if are_primes [i ]:
61
- for j in range (i * i , max_num + 1 , i ):
61
+ for j in range (i * i , max_prime + 1 , i ):
62
62
are_primes [j ] = False
63
63
64
64
return [prime for prime , is_prime in enumerate (are_primes ) if is_prime ]
@@ -94,12 +94,12 @@ def multiply(
94
94
multiply (chain , primes , p , number , n_max , new_sum , primes_d .copy ())
95
95
96
96
97
- def find_longest_chain (chain : list [int ], max_num : int ) -> tuple [ int , int ] :
97
+ def find_longest_chain (chain : list [int ], max_num : int ) -> int :
98
98
"""
99
- Finds the greatest element and length of longest chain
99
+ Finds the smallest element of longest chain
100
100
101
101
>>> find_longest_chain([0, 0, 0, 0, 0, 0, 6], 6)
102
- (6, 1)
102
+ 6
103
103
"""
104
104
105
105
length_max = 0
@@ -139,8 +139,7 @@ def solution(max_num: int = 1000000) -> int:
139
139
140
140
multiply (chain , primes , prime , 1 , max_num , 0 , {})
141
141
142
- chain_start , _ = find_longest_chain (chain , max_num )
143
- return chain_start
142
+ return find_longest_chain (chain , max_num )
144
143
145
144
146
145
if __name__ == "__main__" :
0 commit comments