1 / 5
Feb 2019

import collections
cases = int(input())
for case in range(1, cases + 1):
a ,b = map(int, input().split())
composites = collections.defaultdict(list)
for i in range(2, b + 1):
if i in composites:
for prime in composites[i]:
composites[prime + i].append(prime)
del composites[i]
else:
if i >= a:
print(i)
composites[i * i] = [i]
print()

“”"pretty much out of ideas to solve this any one can modify this “”"
with regards
Thank you.

  • created

    Feb '19
  • last reply

    Feb '19
  • 4

    replies

  • 827

    views

  • 2

    users

  • 1

    link

What problem do you get?

Did you try this4?

With many languages, the indentation is just an aid to reading. With Python of course, it’s far more than that. You really need to preserve the indentation when pasting in Python code, so use the preformatted text tags - the </> button .

import collections
cases = int(input())
for case in range(1, cases + 1):
a ,b = map(int, input().split())
composites = collections.defaultdict(list)

for i in range(2, b + 1):

if i in composites:
  for prime in composites[i]:
    composites[prime + i].append(prime)
  del composites[i]

else:
  if i >= a:
    print(i)
  composites[i * i] = [i]

print()
#my bad for the indentation error
#its getting TLE and i’m out of ideas to make this running
#with regards
#Thank you for the help

That’s why I suggested you try this5. This question has been asked and answered many times, and looking through those previous posts will give you some ideas.