while True:
string=input()
lists = string.split(' ')
num1 = int(lists[0])
num2 = 0
try :
num2 = int(lists[1])
except:
continue
if num1 <= 2:
print(2)
num1 = 3
elif num1 % 2 == 1:
pass
else :
num1+=1
for i in range(num1,num2+1,2):
x, flag = int(i**(1/2)), 0
for j in range(3,x+1,2):
if i%j == 0:
flag = 1
if flag == 0:
print(i)
I got TLE all the time. I don't know how to improve it.
Suggested Topics
Topic | Category | Replies | Views | Activity |
---|---|---|---|---|
Akbar - TLE. Is it even possible to solve it in python? | Python | 5 | 127 | May '24 |