My code is executing properly but the problem for the last output if press keyboard enter only its printing output. i have tried for past three day i could able to find the reason. please help me out my code is:
from sys import stdin,stdout
def prime_sieve( k, n ):
prime = [True for i in range( n + 1 )]
p = 2
while ( p * p <= n ):
# If prime[p] is not changed, then it is a prime
if (prime[p] == True):
# Update all multiples of p
for i in range( p * 2, n + 1, p ):
prime[i] = False
p += 1
for p in range( k, n+1 ):
if prime[p]:
stdout.write(str( p ))
if name == ‘main’:
t = int(stdin.readline())
for i in range(t):
p,n = stdin.readline().split()
prime_sieve(int( p ),int( n ))
This program is showing time limit exceeds. Please help me and thanks in advance.