0

how to write a program to check the prime or not

29th Oct 2016, 1:00 PM
fahma
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
29th Oct 2016, 1:55 PM
Zen
Zen - avatar
+ 1
I believe there is an example of such a program that shows up during the course.
29th Oct 2016, 1:02 PM
Brian
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")
29th Oct 2016, 2:33 PM
Rakesh
Rakesh - avatar