Exercise · Loops · lesson 7 of 7
Exercise: prime number
Write a function is_prime(n) that returns True if n is a prime number and False otherwise. A prime number is greater than 1 and divides evenly only by 1 and by itself.
is_prime(97)→Trueis_prime(91)→Falseis_prime(2)→True
Constraints: n is an integer from 0 to 10000; the numbers 0 and 1 are not prime.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.