Rewrite a Python function given a few specific requirements.
def is_prime(n):
 if n < 2:
 return False
 for i in range(2, n):
 if n % i == 0:
 return False
 return True
def is_prime(n):
 if n < 2:
 return False
 elif n == 2:
 return True
 elif n > 2 and n % 2 == 0:
 return False
 for i in range(3, int(n**0.5)+1, 2):
 if n % i == 0:
 return False
 return True