Python Program to Check Prime Number

In this example, we will write a simple program to take input number from the user and display if it is a prime number or not. To better understand this example, make sure you have knowledge of the following tutorials:-

A positive integer greater than 1 which has no other factors except 1 and the number itself is called a prime number. e.g. 2, 3, 5, 7, 11

Python Program to Check Prime Number:

number = int(input("Enter a number to check prime number: "))
for i in range(2, number):
    if number % i == 0:
        print("It is not a prime number")
        break
else:
    print("It is a prime number")

The output of the above program is:-

Enter a number to check prime number: 55
It is not a prime number
SHARE Python Program to Check Prime Number

You may also like...

Leave a Reply

Your email address will not be published.

Share