A number is a Mersenne Prime if it is both prime and can be written in the form 2n-1, where n is a positive integer.
Your task is to, given any positive integer, determine whether or not it is a Mersenne prime. You may submit either a function which returns a truthy/falsy value, or a full program which performs IO.
Rules:
- As this is code-golf, you should aim to do this in the shortest byte count possible. Builtins are allowed.
- Standard golfing loopholes apply - you cannot read the Mersenne primes from external files, or hardcode them into your program.
- Your program should work for values within your language's standard integer size.
Test Cases
For reference, a list of (known) Mersenne Primes can be found here. Some handy test cases are:
2 -> False
1 -> False
20 -> False
51 -> False
63 -> False
3 -> True
31 -> True
8191 -> True
Merry Christmas, everybody! Have a great holiday, whatever you celebrate :)
2^n-1
\$\endgroup\$n
is always prime, but knowing that changes nothing, the definition is still correct. \$\endgroup\$