#To check number is prime or composite
#to accept the number from user
n=int(input("enter number:"))
#taking any variable as flag and taking its value "true"
x= True
#giving condition to check number is prime or not
for i in range(2,n):
if (n%i==0):
x= False
break # ends the for loop
# no else block because it does nothing ...
#displaying the number is prime or not
if x:
print(n,"is prime number")
else:
print(n,"is composite number")
#to accept the number from user
n=int(input("enter number:"))
#taking any variable as flag and taking its value "true"
x= True
#giving condition to check number is prime or not
for i in range(2,n):
if (n%i==0):
x= False
break # ends the for loop
# no else block because it does nothing ...
#displaying the number is prime or not
if x:
print(n,"is prime number")
else:
print(n,"is composite number")
OUTPUT :
No comments:
Post a Comment