Problem link :: spoj.com/SHORTEN/problems/ISPRIME/
Why runtime error.
[bbone=python,715]import sys
for p in sys.stdin:
s=int(p);
if(pow(2,s-1,s)>1 or pow(3,s-1,s)>1 or pow(5,s-1,s)>1 or pow(5,s-1,s)>1 or s==1):
print("NO")
else:
print("YES")
[/bbone]
Second code also RTE.
Please help
[bbone=python,716]import sys
for l in sys.stdin:
l = l.strip()
if l == '':
continue
s=int(l)
if(pow(2,s-1,s)>1 or pow(3,s-1,s)>1 or s==1):
print"NO"
else:
print"YES"
[/bbone]