Perfect numbers, the pattern continues The well known formula for perfect numbers is 
$$
P_n=2^{n-1}(2^{n}-1).
$$
This formula is obtained by observing some patterns on the sum of the perfect number's divisors. Take for example $496$:
$$
496=1+2+4+8+16+31+62+124+248
$$
one can see that the first pattern is a sequence of powers of $2$ that stops at $16$, the second pattern starts with a prime number, in this case $31$, the rest of them are multiples of $31$, e.g. $2\cdot 31, 4\cdot 31$ and $8\cdot 31$.
But I found that the pattern proceeds after $31$, for example $31=2^5-2^0$, $62=2^6-2^1$, $124=2^7-2^2$ and finally $248=2^8-2^3$, so the perfect number can be written as
$$
496=1+2+4+8+16+(2^5-2^0)+(2^6-2^1)+(2^7-2^2)+(2^8-2^3)
$$
or 
$$
496=(1+2+4+8+16+32+64+128+256) -(1+2+4+8).
$$
So the formula follows very naturally from this.
I've searched but didn't find this formulation anywhere.
Well, is this something new? Has anyone seen this somewhere?
 A: What you have discovered is the special case $\rm\ a = 2,\ m = n-1\ $ of the following simple identity
$\rm\displaystyle\ a^{m}\:\frac{a^n-1}{a-1}\: =\: \frac{a^{m+n}-1}{a-1} - \frac{a^m-1}{a-1}\: =\: 1+a+\cdots+a^{m+n-1} - (1+a+\cdots+a^{m-1})$  
For example, it yields $\ 11111000 = 11111111 - 111\ $ for $\rm\ a = 10,\ m = 3,\ n = 5\:$.
However, except in the special case when the left hand side is an even perfect number, the right hand side is not the (rearranged) sum of the divisors of the left hand side, so it bears little relation to perfect numbers.
A: The patterns you're after tell us nothing about the perfect(ness) of a number.
Since they hold even if the number is not perfect, for example, take n = 6. $2^5 (2^6-1) = 2016 = 2^{10} + 2^9 + ... + 2^5$. Which is valid for any n, since in binary, 2^6-1 is 6-1=5 1's from left, and multiplication by 2^5 is adding 5 zeros from right.
Moreover, the following also hold for any n,
$2^5 (2^6-1) = 2^0 + ... + 2^{6-1} + (2^6-2^0) + (2^{6+1} + 2^1) + ... + (2^{2*6-2} - 2^{6-2})$.
$= 1 + ... + 32 + (2^6 - 2^0) + ... + (2^10 - 2^4)$.
but 2016 is not perfect. 
Here, $2^n-1$ must be prime so that $2^{n-1}(2^n-1)$ is the unique prime factorization of the number, and in which case, the terms in  $\sum_{k=0}^{n-1} 2^k + \sum_{k=0}^{n-2} 2^k(2^n - 1)$ are precisely the divisors of $2^{n-1}(2^n-1)$.
Theorem: If P is an even perfect number, then P = $2^{k-1} (2^k - 1)$ for some k>1 with (2^k - 1) prime.
Proof: 
Suppose P is even perfect. Then we can find k>1 such that $P = 2^{k-1}m$, for m odd. 
Now, $2^{k-1} - 1 = 1 + ... + 2^{k-2}$ (as explained earlier, 2^{k-1} - 1 has k-2 ones). 
i.e explaining why 31 = 1 + 2 + ... + 16.
Write $P = (2^{k-1}-1 + 1)m$. Then $P = (1 + ... + 2^{k-2})m + m$.
The case m is prime: The proper divisors of P are then $1,2, ..., 2^{k-1}, m, 2m, ..., 2^{k-2}m$.
Since P is assumed perfect, $P = 1 + 2 + ... + 2^{k-1} + m + 2m + ... + 2^{k-2}m$.
But $P = (1 + ... + 2^{k-2})m + m$ as shown above.
Therefore, $m = 1 + 2 + ... + 2^{k-1} = 2^{k}-1$ 
i.e $P = 2^{k-1} (2^k - 1)$ (note 2^{k}-1 prime).
The case for m is not prime: Assume without loss of generality $m = p_1 p_2$, neither a unit or even. Then the divisors (hopefully I didn't miss a divisor) of P are:
$1,2, ..., 2^{k-1}, p_1, 2p_1, ... 2^{k-1}p_1, p_2, 2p_2, ... 2^{k-1}p_2, 2m, ..., 2^{k-2}m$.
Taking the sum of the divisors and equating with $P = (1 + ... + 2^{k-2})m + m$. Then 
$m = 1 + 2 + ... + 2^{k-1} + (1 + ... + 2^{k-1})p_1 + (1 + ... + 2^{k-1})p_2 = (2^{k} - 1) (1 + p_1 + p_2)$, but then $p_1 = (1 + p_1 + p_2)$, i.e p_2=-1 or $p_2 = (1 + p_1 + p_2)$, in either case a contradiction.
A: You've observed that $P_5 = 2^4(2^5-1) = 496$ can also be written as the sum of the first 9 powers of two minus the sum of the first four powers of two.
Sums of powers of two
Powers of two written in binary look like $1, 10, 100, 1000, \cdots$ but you can also write them like this $1, 1+1, 11+1, 111+1, \cdots$. This explains why (now in decimal notation) $1 + 2 + 4 + 8 = 15$ and the general sums of this form.
Nine and four
Well obvious $4 = 5-1$, and $9 = 2\cdot 5 - 1$, but where do these come from? Well just multiply out the formula! $2^{n-1}(2^n-1) = 2^{2n-1}-2^{n-1}$.
This explains why the form $(1 + 2 + 4 + 8 + \cdots) - (1 + 2 + \cdots)$ works.
