# How did Mersenne discover Mersenne primes?

So, I was wondering, how did Mersenne come up with the formulae $2^p-1$? Do we have any ideas of how it came to be?

In Elements IX.36 Euclid proves:"If as many numbers as we please beginning from a unit are set out continuously in double proportion until the sum of all becomes prime, and if the sum multiplied into the last makes some number, then the product is perfect". Translation: if $1+2+\dots+2^{n-1}=2^n-1$ is prime then $2^{n-1}(2^n-1)$ is perfect, meaning that it is equal to the sum of its proper divisors like $6=1+2+3$. It is straightforward today, and known to Fermat and Mersenne, that if $2^n-1$ is prime so is $n$, because otherwise $2^n-1$ factorizes as a difference of powers. In other words, find a Mersenne prime and you find a perfect number.
For religious reasons perfect numbers fascinated Pythagoreans, the theorem itself may go back to them, and it came to fascinate mathematicians and numerologists alike for centuries thereafter. A Neo-Pythagorean Nichomachus of Gerasa (c. 100 AD) lists four perfect numbers known in antiquity:"...Only one is found among the units, only one other among the tens, and a third in the rank of the hundreds, and a fourth within the limits of the thousands... And it is their accompanying characteristic to end alternately in 6 or 8, and always to be even". They are $6, 28, 496, 8128$, corresponding to Mersenne primes $2,3,5,7$, but two generalizations Nichomachus implies are incorrect (even perfect numbers do end in 6 or 8, but not alternatively). In 17th century the interest in number theory was rekindled after the translation of Diophantus's Arithmetica, and Mersenne (1644) was the first to extend Nichomachus's list. Eventually Euler proved that all even perfect numbers are given by Euclid's formula. We still do not know if there are infinitely many of them, or if there are any odd ones.