Hi everybody, I have been trying to get an accepted answer for this question for days, but it is giving me runtime error(nzec). I have no idea what is causing this error and how it should be dealt with. I hope you can show me the mistake I'm making.

from array import *
def is_prime(m,n):
    myList= []
    mySieve= array('B', [True]) * (n+1)
    for i in range(2,n+1):
        if mySieve[i]:
            myList.append(i)
            for x in range(i*i,n+1,i):
                mySieve[x]= False
    for a in [y for y in myList if y>=m]:
        print(a)
t= input()
count = 0
while count <int(t):
    m, n = input().split()
    count +=1
    is_prime(int(m),int(n))
    if count == int(t):
        break
    print("\n")
  • created

    Jul '14
  • last reply

    Jul '14
  • 1

    reply

  • 276

    views

  • 1

    user

I think I found the problem. I've used a sieve and that's okay, but it's not efficient for something like 10^9. Eventually, I am gonna use a segmented sieve for much better performance.