1 / 3
Mar 2016

I submitted this following code for prime 1 it works fine on my pycharms but here judge shows tle can someone point out the problem in the code `

`import sys
 def primes_sieve(limit):
    limitn = limit+1
    not_prime = set()
    primes = []

   for i in range(2, limitn):
       if i in not_prime:
           continue

      for f in range(i*2, limitn, i):
           not_prime.add(f)

      primes.append(i)

   return primes

for i in range(int((raw_input()))):
    num1,num2=map(int,raw_input().split())
    primes=primes_sieve(num2)
    for i in primes:
        if i in xrange(num1,num2+1):
              print i
sys.exit(0)
  • created

    Mar '16
  • last reply

    Mar '16
  • 2

    replies

  • 836

    views

  • 2

    users

Your code is broken. Indentation is important in Python. Please correct your post. Select the complete code and click preformatted.
What do you think is the worst case in this problem?

@daft_wullie I implemented Sieve of eratosthenes in the def primes_sieve(limit) and its complexity is O(n(logn)(loglogn)) and the code following it is O(n*m)