how to maximize $f(x,y)=\frac{x+y-2}{xy}$? How to maximize $f(x,y)=\frac{x+y-2}{xy}$ where $x,y \in \{1,2,\ldots,n\}$?
It seems that maximum will occur when $(x,y)=(1,n)$ or $(n,1).$

Note that $f(1,1)=0$ and $f(1,2)=f(2,1)=\frac {1}{2}$
Otherwise,
$$\begin{align}
f(x,y)&=\frac{x+y-2}{xy}\\
&=\frac {1}{y} +\frac {1}{x} - \frac {2}{xy}\\
&=\frac {1}{y} \left(1-\frac {1}{x}\right) +\frac {1}{x}\left(1-\frac {1}{y}\right)\\
&\le\frac {1}{2} \left(1-\frac {1}{x}\right) +\frac {1}{2}\left(1-\frac {1}{y}\right)\\
&\le1-\frac {1}{n}
\end{align}$$
Note that $$f(1,n)= 1-\frac {1}{n}$$
Thus the maximum is $ 1-\frac {1}{n}$ which is achieved at $(1,n)$.
