# Find all positive integers such that $m+n+mn=2016$

What I have till now is that $2016= 2^5\cdot3^2\cdot 7$.

Also, because $m+n+mn=2016$ then $m$ and $n$ must be even. For the rest my idea is to use congruence module $3$, and $7$ to see all cases. Do you have a better idea? Because there are a lot of cases. How would you find the solutions?

• The way to approach this would indeed be to attempt to factorize the LHS as suggested below. You'd perhaps see this if you tried to factorize as much as possible each time. $m+n+mn=m(n+1)+n=m(n+1)+n+1-1=(m+1)(n+1)-1$ – Shuri2060 Aug 16 '17 at 20:52
• Very similar in spirit and solution tohttps://math.stackexchange.com/questions/1267670/find-p-q-r ! – Robert Lewis Aug 16 '17 at 21:04

It's $(m+1)(n+1)=2017$ and $2017$ is a prime number.
Thus, $m+1=1$ and $n+1=2017$ or $m+1=2017$ and $n+1=1$, which says that our equation has no solutions.
Hint $\$ This type of diophantine equation is solvable by a generalization of completing the square. Namely, completing a square generalizes to completing a product, using the AC-method, viz.
$$\begin{eqnarray} &&axy + bx + cy\, =\, d,\ \ a\ne 0\\ \overset{\times\,a}\iff\, &&\!\! (ax+c)(ay+b)\, =\, ad+bc\end{eqnarray}\qquad\qquad$$
So the problem reduces to checking which factors of $\,ad+bc\,$ have above form, a finite process.
If you don't spot the factorisation straight away, you should try to separate the variables e.g. try isolating $m$ by writing $m(n+1)=2016-n$ or $$m=\frac {2016-n}{n+1}$$ Where the right-hand side is an integer. Then divide through so you leave a fraction where the numerator has lower degree than the denominator $$m=\frac {2017}{n+1}-1$$ and you see that if $m$ is an integer, $n+1$ is a factor of $2017$