Doubt in prime generator question

t=int(input())
if t>0:
for x in range(t):
m,n=map(int,input().strip().split())
for num in range(m,n+1):
if num>1:
for i in range(2,num):
if(num%i)==0:
break
else:
print(num,end=" ")
break
print()

what is the problem in this code?
it is running successfully on Jupiter notebook but here it is showing test case failed

Yes, may be you are getting Time Complexity Exceeded because in this ques according to the given constraints they are asking for the segmented sieve solution which is of around NloglogN complexity. And your solution is of complexity nroot(n) type because of this your code is taking too much time while running. Change the logic to segmented sieve it will work fine. Try that out incase you feel any difficulty let me know I will help you out.
If it is clear to you pls resolve this and provide the rating/feedback so that we can improve ourselves.
Thanks :slight_smile:
Happy Coding !!