Solve for $p$ in this equation $2^{p−1}(2^p − 1) = X$.
This is a general formula for finding $X$ (an even perfect number), where $p$ is any prime number. I want to find $p$ when $X$ is given, so that I can say $X$ is an even perfect number if $p$ is prime.

we have $$ 2 2^{p-1}(2^p-1) = (2^p)^2 - 2^p = a^2-a = 2X, $$ with $a = 2^p$- hence $$ a^2-a-2X = 0 $$ the quadratic formula, which has solutions $$ a = \frac{1}{2}\pm \sqrt{1/4 + 2X} $$ skip the negative solution and solve for $p$ in $2^p=a$ $$ p = \log_2(a) = \log_2\left (\frac{1}{2}+\sqrt{\frac{1}{4}+2X} \right) $$