A [Mersenne prime](https://en.wikipedia.org/wiki/Mersenne_prime) is a prime number that can be represented as:
Mn = 2^(n) - 1. Therefore, every Mersenne prime is one less than a power of two. 

Write a function that will return whether the given integer `n` will produce a Mersenne prime or not.

The tests will check random integers up to 2000.

Difficulty: introductory

Starter code:

def valid_mersenne(n):
	

Solutions:
def valid_mersenne(n):
    return n in {2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279}

def valid_mersenne(n):
    '''Currently using the Lucas-Lehmer test.'''
    
    if n < 2:
        return False
    
    if n == 2:
        return True
    
    mersenne = 2**n - 1
    
    residue = 4
    for _ in range(n - 2):
        residue = (residue * residue - 2) % mersenne
    
    return not residue

def valid_mersenne(n):
    return n == 2 or is_prime(n) and lucas_lehmer(n)
    
def is_prime(n):
    from itertools import chain
    return all(n % i != 0 for i in chain([2], range(3, int(n**.5) + 1, 2)))
    
def lucas_lehmer(n):
    s = 4
    M = 2**n - 1
    for _ in range(n - 2):
        s = (s*s - 2) % M
    return s == 0

A000043 = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667, 42643801, 43112609}

def valid_mersenne(n):
    return n in A000043

mersenne_n = (2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279)
def valid_mersenne(n):
    return n in mersenne_n


def valid_mersenne(n):
    mp = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281,
        3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243,
        110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377,
        6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667,
        42643801, 43112609, 57885161, 74207281]
    return n in mp

def valid_mersenne(n):
    return n in [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941]

valid_mersenne = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279}.__contains__