title: Find Mersenne prime numbers using list comprehensions and my code
body: <p>I wrote this code to find prime numbers, but how could I change it to find Mersenne prime numbers?</p>
  
  <pre><code>def prime_test_list(n,known_primes):
  k = 1
  stop_val = len(known_primes)
  if(n&gt;2):
      while k&lt;stop_val:
          cprime = known_primes[k]
          if n%cprime == 0:
              return 0            
          else:
              k+=1
      return 1
  else:
      return 1
  
  def prime_print_list(a):
      n = 2
      known_primes = [1] 
      while(n&lt;a):
          val = prime_test_list(n,known_primes)
          if(val==1):
              known_primes.append(n)            
          n+=1
      print known_primes
  </code></pre>