What is the smallest value of $x + y$ that satisfies $n = 3x + 5y$, if such $(x, y)$ exists, in a closed form, where all variables are natural numbers? (Such solution does not exist for $n=1$, $n=2$, $n=4$ or $n=7$) I am given that $\left\lfloor \frac{n + 2 (2n\ \mathrm{mod}\ 5)}{5} \right\rfloor$ is the solution.
I was able to show that $y \in \{0, 1, 2, 3, 4\}$, as $3y \equiv n\ (\mathrm{mod}\ 5)$ and $\mathrm{gcd}(3, 5) = 1$. But I couldn’t figure out how to get $x$ in closed form.
Any help or suggestions are appreciated. Thanks!
The integer solutions of $n = 5x + 3y$ are given by $x=3t-n$, $y=-5t+2n$, with $t \in \mathbb Z$.
To minimize $x+y=-2t+n$, we need to maximize $t$.
Now:
$x\ge0\ $ iff $\ 3t \ge n$.
$y\ge0\ $ iff $\ 2n \ge 5t$.
$x+y\ge0\ $ iff $\ n \ge 2t$.
These gives $ \frac{n}{3} \le t \le \frac{2n}{5} \le \frac{n}{2} $.
Therefore, $ t \le \left\lfloor\frac{2n}{5} \right\rfloor$ and so the smallest value of $x+y$ is $-2\left\lfloor\frac{2n}{5} \right\rfloor+n$.