Elementary Diophantine equation Solve $(x+y)(xy+1)=2^z$ in positive integres. My attempts is to use $x+y=2^a$, $xy=2^b-1$ and therefore $x,y$ are the roots of the quadratic equation $w^2-2^aw+2^b-1=0$. I try to analyze its dicriminant but it seems to be a dead end...
 A: You have a good start in using uniqueness of factorization.
Because $xy+1\ge x+y$, we have $b\ge a$. Therefore $xy\equiv-1\pmod{2^a}$. As we also have $x\equiv-y\pmod{2^a}$, we can conclude that
$$
x^2\equiv-xy\equiv1\pmod{2^a}.
$$
Assume that $a\ge3$. Then we know that the group $\mathbb{Z}_{2^a}^{\times}$ of units of this residue class ring is isomorphic to $C_2\times C_{2^{a-2}}$. Therefore there are exactly four elements of order two in this group, and they are easily seen to be the residue classes of $\pm1$ and $\pm1+2^{a-1}$. The same reasoning applies to $y$. As we know that $0<x,y<2^a=x+y$, the remaining possibilities are $\{x,y\}=\{1,2^a-1\}$ and $\{x,y\}=\{2^{a-1}-1,2^{a-1}+1\}$.
Both of these work, the first choice leads to $b=a$ the latter to $b=2a-2$.
I leave the cases $a<3$ to you.
A: Hint: Your idea will work. The discriminant is $2^{2a} -4(2^b-1)$. For simplicity divide by $4$. We get $2^{2c}-4\cdot 2^b+1$. Now an analysis of size will bring the problem down to small cases. A useful fact is that there is no perfect square strictly between $x^2$ and $(x+1)^2$.
A: ETA: Jyrki's answer and comments already says this it turns out, and so he really should get the bounty.
Let $x$ and $y$ be positive integers satisfying $x+y\ge 16$. Then $x+y$ must be a power of $2$. Write then, $x+y=2^a$ for some $a \ge 4$. Then $xy+1$ must also be a power of $2$, and as the strict inequality $xy+1 \ge x+y$ for all such $x,y$, it follows that
$$xy+1=(2^a-y)y+1 =2^b$$ $$= 2^ay -y^2+1,$$ where $b$ is an integer satisfying $b>a$. And so $2^a| (y^2-1)$. So from this it follows that $2^{a-1}$ divides one of $y+1, y-1$ [because $4$ can only divide one of $y+1,y-1$]. Likewise, $2^{a-1}$ divides one of $x-1,x+1$. So from this one can deduce WLOG that $2^{a-1}$ divides $y+1$ and $2^{a-1}$ divides $x-1$, as this is the only way $x$ and $y$ can sum to something that is $0$ mod $2^a$. As $x+y=2^a$ and both $x$ and $y$ are nonnegative integers, it follows that $x$ and $y$ must respectively satisfy either the equations $x=2^{a-1}+1$ and $y=2^{a-1}-1$, or $y=2^a-1$ and $x=1$.
However, for each positive integer $a  \ge 4$, note that if on the one hand either $x$ and $y$ satisfy the respective equations $x=2^{a-1}+1$ and $y=2^{a-1}-1$, then $(x,y,z)$, with $z=3a-2$, is a solution: $$(x+y)(xy+1)=2^a((2^{2a-2}-1)+1) = 2^{3a-2}.$$ If on the other hand $x=1$ and $y=2^a-1$ then $(x,y,z)$, with $z=2a$ is also a solution: $$(x+y)(xy+1)=(1+y)(1+y)$$ $$=2^a×2^a =2^{2a}.$$
A: The idea of discriminant works nicely, as @Jyrki, @Andre and @Mike answered. Yet, I think of another (perhaps more "number theory"ish :) way.

First, the equation is symmetric in $x$ and $y$, hence without loss of generality, we assume $x\ge y$.

Since $xy+1$ divides $2^z$ and is not equal to $1$, then it should be even, meaning that $x$ and $y$ should both be odd. Let $x=2a+1$ and $y=2b+1$. A replacement yields
$$
4(a+b+1)(2ab+a+b+1)=2^z.
$$
Since $a+b+1$ is a power of $2$, $2ab+a+b+1$ will too be another power of $2$ only if $2ab=a+b+1$ or $2ab=0$ (a simple proof follows from assuming contrary). The latter case yields $b=0$ (or $a=0$) which means $y=1$ and $(x+1)^2=2^z$. Therefore, a set of solutions is found among $(x,y,z)=(2^u-1,1,2u)$ (and obviously $(x,y,z)=(1,2^u-1,2u)$). The former case yields
$$
{2ab=a+b+1\implies
\\(2a-1)(2b-1)=3\implies
\\(x-2)(y-2)=3\implies
\\x=5,y=3\implies z=7
\\\text{ or }
\\x=3,y=5\implies z=7
}.
$$

In conclusion, all the solutions are
$$
(x,y,z){\in
\left\{(2^u-1,1,2u):u\in\Bbb N\right\}
\\\cup
\left\{(1,2^u-1,2u):u\in\Bbb N\right\}
\\\cup
\left\{(3,5,7),(5,3,7)\right\}
}
$$

