Monday, 6 April 2020

Program: Check input number is prime or not in Python

n = eval(input("enter an number"))
flag=0
for i in range(2,n//2):
    if n%i==0:
        flag=1
        break
if flag ==0:
    print(n," is prime")
else:
    print(n,"is composite number")

No comments:

Post a Comment