24. The numbers $x, y, p$ and $q$ are all integers. $x$ and $y$ are variable and $p$ and $q$ are constant and positive. The four integers are related by the equation $x y=p x+q y$.
When $y$ takes its maximum possible value, which expression is equal to $y-x$ ?
A $p q-1$
B $(p-1)(q-1)$
C $(p+1)(q-1)$
$\mathrm{D}(p-1)(q+1)$
$\mathrm{E}(p+1)(q+1)$
Solution
D
Since
$$
x y=p x+q y,
$$
we have
$$
x y-q y=p x .
$$

Therefore
$$
(x-q) y=p x .
$$

Hence
$$
y=\frac{p x}{x-q}=p+\frac{p q}{x-q} .
$$

Since $p$ and $q$ are constant, $y$ attains its maximum value when $x$ has the value that maximises $\frac{p q}{x-q}$. Since $p q>0$, this is the value of $x$ for which $x-q$ attains its minimum positive value.
Because $x$ and $q$ are integers the minimum positive value of $x-q$ is 1 . This occurs for $x=q+1$. For this value of $x$, we have $y=p+p q$, which is an integer.
It follows that when $y$ takes its maximum possible value, $y-x=(p+p q)-(q+1)=$ $p(q+1)-(q+1)=(p-1)(q+1)$.

For INVESTIGATION
24.1 (a) Find all the solutions of the equation
$$
x y=6 x+5 y
$$
in which $x$ and $y$ are positive integers.
(b) Find the maximum value of $y$ which occurs among these solutions.
(c) Verify that this value of $y$ is $p+p q$ with $p=6$ and $q=5$.