Return the number of chains with a starting number below one million which contain exactly n non-repeating terms. >>> solution(10,1000) 28
(num_terms: int = 60, max_start: int = 1000000)
| 96 | |
| 97 | |
| 98 | def solution(num_terms: int = 60, max_start: int = 1000000) -> int: |
| 99 | """ |
| 100 | Return the number of chains with a starting number below one million which |
| 101 | contain exactly n non-repeating terms. |
| 102 | >>> solution(10,1000) |
| 103 | 28 |
| 104 | """ |
| 105 | return sum(1 for i in range(1, max_start) if chain_length(i) == num_terms) |
| 106 | |
| 107 | |
| 108 | if __name__ == "__main__": |