Check a given number is prime or not in python


#Check a given number is prime or not---
#Alamgir Hossain#CSE, JUSTn = input("Enter the number : ")

isprime = 0if n==1:
    isprime = 1
for i in range(2,n/2+1):
    if n%i==0:
        isprime = 1        break
if isprime==0:
    print "The number is prime"else:
    print "The number is not prime."

No comments:

Post a Comment