title: Efficient method for generating lists of large prime numbers
body: <p>What I'm trying to figure out is when I run this code for smaller numbers it returns the list just fine, but for larger numbers (I would call this small in the context of what I'm working on.) like 29996299, it will run for a long time, I've waited for 45 minutes with no results and had to end up killing the program. What I was wondering was whether there was a more efficient way to handle numbers whose scale was larger than 4 or 5 digits. I've tested a few permutations of the range function to see if there was a better way to handle the limits of the list I want to produce but nothing seems to have any effect on the amount of time it takes to do the computation. I'm new to python and am not that experienced as a programmer. Thank you for your time.</p>
  
  <p>ran the program again before submitting this post and it took an hour and a half or so.</p>
  
  <p>function of the program is to take the User selected number, use it to generate a lower bound, find all primes between the bound and input and append to list, then generate a secound upper bound and find all primes and then append to list, to create a list that extends forwards and backwards from the initial number. 
  the program works like I expect it to but not as quickly as I need it to since the numbers I'm going to be dealing with are going to get large quickly, almost doubling at each phase.</p>
  
  <pre><code>initial_num = input("Please enter a number. ") 
  
  lower_1 = int(initial_num) - 1000
  upper_1 = int(initial_num)
  list_1 = []
  
  for num in range(lower_1,upper_1):
     if num &gt; 1:
         for i in range(2,num):
             if (num % i) == 0:
                 break
         else:
             list_1.append(num)
  
  lower_2 = list_1[-1]
  upper_2 = list_1[-1] + 2000
  list_2 = []
  
  for num in range(lower_2,upper_2 +1):
     if num &gt; 1:
         for i in range(2,num):
             if (num % i) == 0:
                 break
         else:
             list_2.append(num)
  
  list_3 = list_1 + list_2[1:]
  
  print list_3
  </code></pre>