MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_123/sol1.py:80–97  ·  view source on GitHub ↗

Returns the least value of n for which the remainder first exceeds 10^10. >>> solution(1e8) 2371 >>> solution(1e9) 7037

(limit: float = 1e10)

Source from the content-addressed store, hash-verified

78
79
80def 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
100if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 1

sieveFunction · 0.70

Tested by

no test coverage detected