1# Time Efficient Primality Check in Python
2
3def primeCheck(n):
4 # 0, 1, even numbers greater than 2 are NOT PRIME
5 if n==1 or n==0 or (n % 2 == 0 and n > 2):
6 return "Not prime"
7 else:
8 # Not prime if divisable by another number less
9 # or equal to the square root of itself.
10 # n**(1/2) returns square root of n
11 for i in range(3, int(n**(1/2))+1, 2):
12 if n%i == 0:
13 return "Not prime"
14 return "Prime"