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

Function is_prime

project_euler/problem_131/sol1.py:18–29  ·  view source on GitHub ↗

Determines whether number is prime >>> is_prime(3) True >>> is_prime(4) False

(number: int)

Source from the content-addressed store, hash-verified

16
17
18def is_prime(number: int) -> bool:
19 """
20 Determines whether number is prime
21
22 >>> is_prime(3)
23 True
24
25 >>> is_prime(4)
26 False
27 """
28
29 return all(number % divisor != 0 for divisor in range(2, isqrt(number) + 1))
30
31
32def solution(max_prime: int = 10**6) -> int:

Callers 1

solutionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected