Let $m,n\in \mathbb{N}$. Let $q,r$ be the quotient and remainder of $\frac{m^2+n^2}{m+n}$. If $q^2+r=17$, find all pairs of $(m,n)$.
My first thought was trying polynomial division, but I did not see how it could have helped. I also thought at factoring $m^2+n^2$, but to no success. How should I proceed?
Clearly, $1\leq q \leq 4$. We can consider the 4 possible values of $q$ in turn.
If $q=1$, then $r=16$, and we have $m^2+n^2 = 1(m+n)+16$, or $(2m-1)^2 + (2n-1)^2 = 66$, which has no solutions $m, n \in \mathbb{N}$.
If $q=2$, then $r=13$, and we have $m^2+n^2 = 2(m+n)+13$, or $(m-1)^2 + (n-1)^2 = 15$, which has no solutions $m, n \in \mathbb{N}$.
If $q=3$, then $r=8$, and we have $m^2+n^2 = 3(m+n)+8$, or $(2m-3)^2 + (2n-3)^2 = 50$, which has no solutions $m, n \in \mathbb{N}$ satisfying $m+n>r$.
If $q=4$, then $r=1$, and we have $m^2+n^2 = 4(m+n) + 1$, or $(m-2)^2+(n-2)^2 = 9$, which has solutions $(m,n) \in \{(5,2), (2,5)\}$.
Thus, the full set of solutions is $(m,n) \in \{(5,2), (2,5)\}$.