Fast,code in pythob


#1

class Solution:
# @param A : integer
# @return an integer
def isPrime(self, n):
if n <= 1:
return 0
if n == 2:
return 1
if n > 2 and n % 2 == 0:
return 0

    max_div = math.floor(math.sqrt(n)) 
    for i in range(3, 1 + max_div, 2): 
        if n % i == 0: 
            return 0
    return 1