Programs
Q. Write a code to check whether no is prime or not. Condition use function check() to find whether entered no is positive or negative ,if negative then enter the no, And if yes pas no as a parameter to prime() and check whether no is prime or not?
import math as m
n=int(input())
p=0
if(n>1):
for i in range(2,int(m.sqrt(n))+1):
if(n%i==0):
p=1
break;
if(p==0):
print("number is prime!")
else:
print("number is not prime");
else:
print("number is not prime!");
Comments
Post a Comment