Skip to content
CampusEduX

Prime Number Checker

Mediumpython
Learn the Concept: Loops

Determine whether a given number is prime, using a for loop with loop-else.

What is a prime number?

Ans:a whole number greater than 1 that has no divisors other than 1 and itself.

Approach: try dividing n by every number from 2 up to n-1. If none divide evenly, the loop finishes without a break and confirms the number is prime.

Input: One line: a whole number n.

Output: One line: <n> is a prime number or <n> is not a prime number.

Related Problems

Input (stdin)

Output

Run your code to see output here...