Given an integer n, return true if n is a prime number, and false otherwise.
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
For example, isPrime(7) returns true because 7 is only divisible by 1 and 7, while isPrime(4) returns false because 4 is divisible by 2.
n = 7truen = 4falsen = 1false-10^9 <= n <= 10^9Numbers less than 2 are not prime.Run your code to see results
Use Cmd+Enter to run