1
$\begingroup$

It's easy to see that this equation always has a solution:

$$a=n+2,\quad b=2$$

Because it can be rewritten:

$$a=\frac{b+n}{b-1} \tag{1}$$

Moreover, for even $n$ there are no more nontrivial solutions, obviously, because we would have a ratio of odd to even or even to odd. (Never mind, that's not true, of course, even numbers can divide odd. However, there are other reasons for trouble with even $n$.)

I need to find solutions with minimal $a-b$, but $a \neq b$ for odd values of $n$. Is there a general formula or at least an algorithm?

Since $a$ and $b$ are interchangeable, assume $a >b$.

  • 2
    The equation can be written as $(a-1)(b-1)=n+1$.2017-02-03

1 Answers 1

2

We can rewrite this as $ab-a-b+1=n+1$, or $(a-1)(b-1)=n+1$. Hence the smallest $a-b$ is achieved then $a-1$ is the smallest divisor of $n+1$ greater than $\sqrt{n+1}$ (or equal if you were to allow $a=b$).

By the way, the ratio of even to odd can be integer - just look at $\frac{6}{3}$. For example, for $n=14$, you can take $a=6,b=4$, so this is another nontrivial solution for an even $n$.

  • 0
    @ Wojowu, thanks, I messed up about even $n$. But there are other reasons for trouble with even $n$ - the number of solutions is always much smaller for the cases I checked2017-02-03
  • 0
    @YuriyS If you drop the assumption that $a>b$, then the number of solutions is precisely the number of divisors of $n+1$. Since $n+1$ is odd if $n$ is even, there will often be less solutions, but I don't see why this is any kind of trouble; my solution works just fine.2017-02-03
  • 0
    Your answer is good, it's me who has trouble2017-02-03
  • 0
    If you have any more questions, feel free to ask, either in a comment or add to your question.2017-02-03