$\frac{a^2+b^2+1}{ab+1}=k$. Find $k$ $a$ and $b$ are positive integers such that
$$\frac{a^2+b^2+1}{ab+1}=k$$
where $k$ is positive integer. Find all values $k$
My work:
$a$ is the root of the equation
$$x^2-kbx+b^2+1-k=0$$
Let $c$ is another root of this equation. Then
$c=kb-a$ and $ac=b^2+1-k$

Note that, mod $ab+1$, $0=b^2(a^2+b^2+1)=b^4+b^2+1$. Therefore, $b^4+b^2+1 > 0$ is divisible by $ab+1$, thus $b(b^3+b) \geq ab$. So if $b \neq 0$, then this can be written as $k \leq b^2+1$ which entails (if $a > 0$), $c \geq 0$. 
Take now, for a given $k$, $(a,b)$ a solution in non-negative integers with $a \geq b$ and $a+b$ minimal. Assume $b \neq 0$ (hence $ab>0$). 
Then by minimality $c \geq a$ (since $(c,b)$ is a solution) thus $a^2 \leq ac = b^2+1-k \leq b^2$, so $a=b$. But this implies $a=b=0$, a contradiction. So $b=0$ and $k=a^2+1$. 
The possible values of $k$ are thus exactly all the $x^2+1$ for integers $x$. 
