from math import sqrt def primetest3(x): if x < 2 or (x > 2 and x % 2 == 0): return False d = 3 while d <= sqrt(x): if x % d == 0: return False d += 2 return True