3 / 3
Nov 2014

Hello

I'm usig this code, have an error runtime error (NZEC) , could, something help me with this.

Intervalos = []
def NumerosPrimos(n):
    prime = [True] * n
    for p in xrange(3, n, 2):
        if p ** 2 > n: 
            break
        if prime[p]:
            for i in xrange(p * p, n, 2 * p):
                prime[i] = False
    return [2] + [p for p in xrange(3, n, 2) if prime[p]]
CantidadTest = int(raw_input())
print ""
for Cantidad in xrange(CantidadTest):
	Tmp1,Tmp2 = raw_input().split()
	Intervalos.append([int(Tmp1),int(Tmp2)])
for Salida in xrange(CantidadTest):
	primos = NumerosPrimos(int(Intervalos[Salida][1])+1)
	for p1 in xrange(len(primos)):
		if primos[p1] >= int(Intervalos[Salida][0]):
			print primos[p1]
	print ""

Thanks for your help

Best Regards

  • created

    Oct '14
  • last reply

    Nov '14
  • 2

    replies

  • 310

    views

  • 2

    users

Look at the contraints!

[bbone=Python,749]>>> [True]*1000000000
Traceback (most recent call last):
File "", line 1, in
MemoryError
[/bbone]