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

Function solution

project_euler/problem_131/sol1.py:32–49  ·  view source on GitHub ↗

Returns number of primes below max_prime with the property >>> solution(100) 4

(max_prime: int = 10**6)

Source from the content-addressed store, hash-verified

30
31
32def solution(max_prime: int = 10**6) -> int:
33 """
34 Returns number of primes below max_prime with the property
35
36 >>> solution(100)
37 4
38 """
39
40 primes_count = 0
41 cube_index = 1
42 prime_candidate = 7
43 while prime_candidate < max_prime:
44 primes_count += is_prime(prime_candidate)
45
46 cube_index += 1
47 prime_candidate += 6 * cube_index
48
49 return primes_count
50
51
52if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 1

is_primeFunction · 0.70

Tested by

no test coverage detected