Write the logic to check whether a number is prime.
Implement is_prime(n) to return True when n is prime and False otherwise. A prime number is an integer greater than 1 with exactly two positive divisors. Optimize the check so it does not test every value up to n.
Function: def is_prime(n):
Input: One integer n. Output: A Boolean.
def is_prime(n):