Returns the least value of n for which the remainder first exceeds 10^10. >>> solution(1e8) 2371 >>> solution(1e9) 7037
(limit: float = 1e10)
| 78 | |
| 79 | |
| 80 | def solution(limit: float = 1e10) -> int: |
| 81 | """ |
| 82 | Returns the least value of n for which the remainder first exceeds 10^10. |
| 83 | >>> solution(1e8) |
| 84 | 2371 |
| 85 | >>> solution(1e9) |
| 86 | 7037 |
| 87 | """ |
| 88 | primes = sieve() |
| 89 | |
| 90 | n = 1 |
| 91 | while True: |
| 92 | prime = next(primes) |
| 93 | if (2 * prime * n) > limit: |
| 94 | return n |
| 95 | # Ignore the next prime as the reminder will be 2. |
| 96 | next(primes) |
| 97 | n += 2 |
| 98 | |
| 99 | |
| 100 | if __name__ == "__main__": |