@@ -47,18 +47,18 @@ def sum_primes(primes_degrees: dict[int, int], num: int) -> int:
4747 )
4848
4949
50- def generate_primes (max_num : int ) -> list [int ]:
50+ def generate_primes (max_prime : int ) -> list [int ]:
5151 """
52- Calculates the list of primes up to and including `max_num `.
52+ Calculates the list of primes up to and including `max_prime `.
5353
5454 >>> generate_primes(6)
5555 [2, 3, 5]
5656 """
57- are_primes = [True ] * (max_num + 1 )
57+ are_primes = [True ] * (max_prime + 1 )
5858 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 ):
6060 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 ):
6262 are_primes [j ] = False
6363
6464 return [prime for prime , is_prime in enumerate (are_primes ) if is_prime ]
@@ -94,12 +94,12 @@ def multiply(
9494 multiply (chain , primes , p , number , n_max , new_sum , primes_d .copy ())
9595
9696
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 :
9898 """
99- Finds the greatest element and length of longest chain
99+ Finds the smallest element of longest chain
100100
101101 >>> find_longest_chain([0, 0, 0, 0, 0, 0, 6], 6)
102- (6, 1)
102+ 6
103103 """
104104
105105 length_max = 0
@@ -139,8 +139,7 @@ def solution(max_num: int = 1000000) -> int:
139139
140140 multiply (chain , primes , prime , 1 , max_num , 0 , {})
141141
142- chain_start , _ = find_longest_chain (chain , max_num )
143- return chain_start
142+ return find_longest_chain (chain , max_num )
144143
145144
146145if __name__ == "__main__" :
0 commit comments