Exercise: Check Whether a Number is Prime

Use what you've learned so far to check if a number is prime.

We'll cover the following

Prime numbers are numbers that are only divisible by itself and 1. Examples of these are the following:

2, 3, 5, 7, 11, 13

Problem statement

The following program checks whether the given number is a prime number or not.

However, if we pass the number 1 to the is_prime function, it will report True, indicating that 1 is a prime number when it is not.

The same issue occurs when the is_prime function is called on negative numbers, which are also not prime numbers.

Therefore, your task is to correct this problem.

Input

n = 1

Output

False

Challenge

This problem has been designed for you to practice freely, so try to solve it on your own first. Take some time and think about the different concepts that have been explored in the course so far.

If you feel stuck, you can always check out the solution review provided in the next lesson.

Good luck!

Get hands-on with 1400+ tech skills courses.