0
how to write a program to check the prime or not
3 odpowiedzi
+ 4
http://www.sololearn.com/app/sololearn/playground/cd4hDkhM6tm7/
import math
def isPrime(n):
for i in range(2, math.floor(math.sqrt(n))+1):
if n % i == 0:
return False
return True
+ 1
I believe there is an example of such a program that shows up during the course.
0
n=int(input("Enter the number"))
count=0
i=1
while i<=n:
if n%i==0:
count=count+1
i=i+1
if count==2:
print("Prime number")
else:
print("Not prime number")