Python Program to check a number is prime or not
In this program, You will learn how to check a number is prime or not in Python.
Some list are: 2 3 5 7 9 11 13
Example: How to check a number is prime or not in Python.
n = int(input("Enter a number:"))
i = 2
p = 1
while i < n:
if n % i == 0:
p = 0
break
i = i + 1
if p == 1:
print("Number is prime:", n)
else:
print("Number is not prime:", n)
Output:
Enter a number:7
Number is prime: 7