+ 1
Find prime number or not prime number
3 Answers
+ 7
Maninder Singh Since multiplication is commutative, it is enough to check from 2 to sqrt(x) actually. It saves you a lot of "empty iterations" (and computation power) especially for really large numbers.
+ 5
x=int(input())
d=[]
for i in range(1,x):
if(x==1):
print('Not Prime')
elif(x%i==0):
d.append(i)
if(len(d)>1):
print('Not Prime')
break
if(len(d)==1):
print('Prime')