Python to verify if a number is prime number or not

Python to verify if a number is prime number or not

A prime number is one which is only divisible by 1 and itself. Numbers 0 and 1 are not prime numbers.

Below program is used to identify if a number is prime or not.

number = int(input("Enter number to verify prime number:"))

if (number > 1):
    for num in range(2,number):
        if(number%num) == 0:
            print("Not prime number")
            break
    else:
        print("prime number")
else:
    print("not a prime number")

Post a Comment

0 Comments