WAP to check the number is prime or not python

 PYTHON PROGRAM


"""

WAP to check the number is prime or not

1.Let start by taking input any number ftim the user.

2.Now use for loop and check your number whether it is divisible by 1 to itself numbers. and count how many times it is completely divisible.

3.If the value of count is 2 then print that number is prime otherwise not prime.

"""




num=int(input("Enter a number:"))

count=0

for i in range(1,num+1):

if num%i==0:

count+=1

else:

continue

if count==2:

print("Prime number.")

else:

print("Not prime")

No comments:

Powered by Blogger.