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

Function solution

project_euler/problem_007/sol3.py:65–82  ·  view source on GitHub ↗

Returns the n-th prime number. >>> solution(6) 13 >>> solution(1) 2 >>> solution(3) 5 >>> solution(20) 71 >>> solution(50) 229 >>> solution(100) 541

(nth: int = 10001)

Source from the content-addressed store, hash-verified

63
64
65def solution(nth: int = 10001) -> int:
66 """
67 Returns the n-th prime number.
68
69 >>> solution(6)
70 13
71 >>> solution(1)
72 2
73 >>> solution(3)
74 5
75 >>> solution(20)
76 71
77 >>> solution(50)
78 229
79 >>> solution(100)
80 541
81 """
82 return next(itertools.islice(prime_generator(), nth - 1, nth))
83
84
85if __name__ == "__main__":

Callers 1

sol3.pyFile · 0.70

Calls 1

prime_generatorFunction · 0.70

Tested by

no test coverage detected