Loops · Intermediate · 80 XP · about 8 min
Write a function called is_prime(n) that returns 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.
is_prime(7) # Returns True is_prime(4) # Returns False is_prime(2) # Returns True is_prime(1) # Returns False is_prime(17) # Returns True
False for numbers less than 2True for prime numbersReady?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.