Given an integer n, write a function that returns True if n is a prime number and False otherwise. A prime number is greater than 1 and has exactly two positive divisors: 1 and itself.
Constraints
-10^9 <= n <= 10^9
The function should correctly handle negative numbers, 0, and 1
Aim for better than O(n) time by limiting divisor checks
Function Signature
defis_prime(n):
Interviewer
Your question is Check Whether a Number Is Prime. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.