title: got SPOJ prime1 wrong answer in python
body: <p>I am getting Wrong Answer with the following code in python for SPOJ's PRIME1 problem at <a href="http://www.spoj.com/problems/PRIME1/" rel="nofollow">http://www.spoj.com/problems/PRIME1/</a>. I have tested it on various testcases myself, but cannot find a failing testcase. Can someone please spot the problem in my code?</p>
  
  <pre><code>from math import sqrt
  
  def sieve_1(n):
      l = [True for i in xrange(int(sqrt(n)) + 1)]
      m = []
      for i in xrange(2, int(sqrt(n)) + 1):
          if l[i] == True:
              m.append(i)
              for j in xrange(i, int(sqrt(n)) + 1, i): l[j] = False
      #print m
      return m
  
  def sieve_2(a, b):
      l = sieve_1(b)
      t = a
      r = [True for i in xrange(a, b + 1)]
      if a == 1 : r[0] = False
      for p in list(l):
          if (a/p)*p != a: a = (a/p)*p + p
          for i in xrange(a - t, b + 1 - t, p): r[i] = False
      for i in list(l):
          if i &gt; t: r[i - t] = True
      return r
  
  
  def prime(a, b):
      l = sieve_2(a, b)
      for i in xrange(0, b + 1 - a):
          if l[i] == True:
              print i + a
  
  
  n = int(raw_input())
  for i in xrange(n):
      a, b = map(int, raw_input().split())
      prime(a, b)
      if i != n - 1: print' '
  </code></pre>