Challenge: Find out if the Given Number is Prime

Test your understanding by solving a simple challenge in this lesson.

Problem statement

You are given a number. Your task is to find whether the given number is prime or not.

📝 A number is prime if it is only divisible by 1 and itself.

📝 1 is not a prime number, and 2 is the only even prime number.

Input

We have already initialized the variable number at the backend.

Output

  • If the given number is prime, you should print prime to the console.

  • If the given number is not prime, you should print not prime to the console.

Sample input

int number = 31;

Sample output

prime

Coding exercise

Before diving directly into the solution, try to solve it yourself. Then check if your code passes all the test cases.

📝 Please use the variable number for the input and print your output to the console, or your code will not execute.

Good luck! 👍

Get hands-on with 1200+ tech skills courses.