Determine all pairs of positive integers $(x,n)$ which satisfy the condition $$x^3+2x+1=2^n.$$
My work so far:
No solution exists for $n=1$. For $n=2$ we get $x=1$.
We show that no solutions exist for $n\ge3$. Suppose that $n \ge 3$. Obviously, $x$ is odd. Then $x^2+2\equiv 3 \pmod 8$. As with the original equation $x(x^2+2)\equiv -1 \pmod 8$, then $x\equiv 5\pmod 8$.
I can not get a contradiction.
Suppose $n \ge 3$.
Note that $x \equiv 5 \pmod 8$.
Since $x^3+2x+1 \equiv 3x+1 \equiv 1 \pmod 3$ by Fermat's little theorem, $2^{n}$ divided by $3$ has a remainder of $1$. This implies that $n$ is a even number. Let $n=2k$.
By adding $2$ to each side, the equation can be factorized so that $$(x+1)(x^2-x+3)=2^{2k}+2.$$
Since $x^2-x+3 \equiv 23 \equiv 7 \pmod 8$, there exists a prime number $p$ where $p \equiv 5, 7\pmod8$ such that $p$ divides $x^2-x+3$. (If there is no such $p$, then $x^2-x+3 \equiv 3^{k} \pmod 8$. But $3^{k} \not \equiv 7 \pmod 8$). Since $x^2-x+3$ is a factor of $2^{2k}+2$, $p$ divides $2^{2k}+2$.
That means $(2^{k})^2 \equiv -2 \pmod p$. But $-2$ is a non-quadratic residue of $p$ since $p \not\equiv 1,3\pmod 8$. A contradiction.