Find all positive integers $x,y,z$ for which the expression is true. So I wish to find all the positive integers $x,y,z$ such that the following expression is true.
$$\frac{-1 + x + y + x y}{-1 - x - y + x y} = z$$
The problem is that the expression does not simplify any further as far as I can tell. The only constraint that I can think of is the denominator has to be greater than zero and so we get that $y > \frac{x+1}{x-1}$. We can also write the left-hand side as:
$$\frac{(x+1)(y+1)-2}{(x-1)(y-1)-2} = z$$
But I still can't see the algorithm that would let me find the integer solutions. Any ideas?
PS. Wolfram can easily find the solutions but I wish to know how it approaches the problem.
 A: Let $x$, $y$ and $z$ be positive integers such that
$$\frac{-1+x+y+xy}{-1-x-y+xy}=z.\tag{1}$$
First, it should be clear that $x\geq2$ and $y\geq2$ because the ratio $z$ is positive, and that $z\geq2$ because the numerator is strictly greater than the denominator. If $x=2$ then $(1)$ simplifies to
$$z=\frac{1+3y}{-3+y}=3+\frac{10}{y-3},$$
which shows that $y-3$ divides $10$. This yields the following triplets $(x,y,z)$ as solutions:
$$(2,4,13),\quad(2,5,8),\quad(2,8,5),\quad(2,13,4).$$
Of course by symmetry in $x$ and $y$ we also get the following solutions:
$$(4,2,13),\quad (5,2,8),\quad(8,2,5),\quad(13,2,4).$$
For the remaining solutions we have $x,y\geq3$. Clearing the denominator in $(1)$ shows that
$$(z-1)xy-(z+1)x-(z+1)y-(z-1)=0,$$
and multiplying by $(z-1)$ we can express this as
$$\big((z-1)x-(z+1)\big)\big((z-1)y-(z+1)\big)=2(z^2+1).\tag{2}$$
Of course, because $x,y\geq3$ we see that
$$2(z^2+1)=\big((z-1)x-(z+1)\big)\big((z-1)y-(z+1)\big)\geq(2z-4)^2=4(z-2)^2,$$
which implies that $z\leq7$. Plugging these values of $z$ into $(2)$ we get the identities
\begin{eqnarray*}
(x-3)(y-3)&=&10,\\
(x-2)(y-2)&=&5,\\
(3x-5)(3y-5)&=&34,\\
(2x-3)(2y-3)&=&13,\\
(5x-7)(5y-7)&=&74,\\
(3x-4)(3y-4)&=&25,\\
\end{eqnarray*}
This yields the following triplets $(x,y,z)$ of solutions:
\begin{eqnarray*}
z=2:&\qquad (4,13,2),&&\quad (5,8,2),\quad (8,5,2),\quad
 (13,4,2)\\
z=3:&\qquad (3,7,3),&&\quad (7,3,3),\\
z=4:&\qquad (2,13,4),&&\quad(13,2,4),\\
z=5:&\qquad (2,8,5),&&\quad(8,2,5),\\
z=6:&\qquad \text{None,}\\
z=7:&\qquad (3,3,7).
\end{eqnarray*}
These $15$ solutions are all positive integral solutions to $(1)$. Note that for $z=4$ and $z=5$ we have found some earlier solutions with $x=2$ or $y=2$ again.

Original sketch of answer:
Let $x$, $y$ and $z$ be positive integers such that
$$\frac{-1+x+y+xy}{-1-x-y+xy}=z.$$
Clearly the numerator is strictly greater than the denominator and so $z\geq2$. It follows that
$$-1+x+y+xy\geq2(-1-x-y+xy),$$
and a bit of rearranging shows that this is equivalent to
$$(x-3)(y-3)\leq10.$$
This greatly limits the possible values for $x$ and $y$. Without loss of generality $x\leq y$, and this inequality shows that then $x\leq6$. Moreover it is clear from this inequality, that for $x>3$ there are only a few values of $y$ to check. For $x=3$ identity $(1)$ reduces to
$$z=\frac{2+4y}{-4+2y}=2+\frac{5}{y-2},$$
which shows that either $y=3$ or $y=7$. Similarly, for $x=2$ identity $(1)$ reduces to
$$z=\frac{1+3y}{-3+y}=3+\frac{10}{y-3}.$$
which shows that $y\in\{4,5,8,13\}$.
