title: Avoiding reaching memory limits while making a list in Python
body: <p>This is Problem 1352C over at Codeforces and I'm using Python 3.x to solve it, so memory is a concern.</p>
  <pre><code>finl = []
  for i in range(n):
      div, no = map(int, input().split())
      lis = [j for j in range(no*div) if j%div != 0]
  
      finl.append(str(lis[no-1]))
  print(&quot;\n&quot;.join(finl)) 
  </code></pre>
  <p>This is my code so far. I take each case, and make a list with all the numbers not divisible by the number in question, <code>div</code> here, and <code>no</code> is the nth number which is the necessary output. This is a simplistic approach, and understandably, I am reaching the memory limit in just the first set of numbers.</p>
  <p>My question here is: how can I forego making a whole list (and thus wasting memory) and just save the output that I need (the <code>no</code>th entry) to the <code>finl</code> list (the list of outputs I made that gets printed in the end)? I want to stick with this approach for now, and I couldn't find something similar that's been answered (without looking at the problem's solutions and thus skipping part of the problem-solving process)</p>