Even perfect numbers and a relationship with polygonal numbers Let $\sigma(m)=\sum_{d\mid m}d$ the sum of divisors function, for example $\sigma(6)=1+2+3+6=12$. 

Question. I don't know if this exercise was in the literature, and I believe that I know how prove the following, but can you give for example a proof of B) to do a comparision with my computations? Is my attempt for A) a rigurous proof or can you give more details? Thanks in advance.

A) If $n$  is an even perfect number then 
$$\sigma(n)-\{\text{the greater perfect square}<\sigma(n)\}=\text{the Mersenne prime associated with n}:=\delta(n)$$
B) If $n$  is an even perfect number then 
$$n-\{\text{the greater triangle number}<n\}=\text{the Mersenne prime associated with n}:=\delta(n).$$
My proof  for A). By Euler's theorem for even perfect numbers $n=2^{p-1}\cdot(2^p-1)$, where $\delta(n)=2^p-1$ is the corresponding Mersenne prime, by comparison of the factor of $n$ the grater square perfect that is less than $2^p(2^p-1)$ is $(2^p-1)^2$, and this difference is the Mersenne prime, $2^p(2^p-1)-(2^p-1)^2=(2^p-1)(2^p-2^p+1)=2^p-1$.

It may be clearer to calculate as follows. 
Let $P=2^p-1$. Then $n=\frac{P(P+1)}{2}$. The greatest triangular number less than $n$ is $\frac{(P-1)P}{2}$. Subtract. We have 
$$\frac{P(P+1)}{2}-\frac{(P-1)P}{2}=\frac{P}{2}((P+1)-(P-1))=P.$$
