0

If $a<b$ what is the maximum possible value of a mod b+ b mod a.

I tried several times, the answer always came out to be 2a-2. But then it is not a choice. Am I right?

user2838619
  • 3,120

3 Answers3

3

Since $b>a$, it follows that $a\mod b =a$. Further more $b \mod a$ can take the values $0,1,2...a-1$, and the largest of these values being $a-1$, so said maximum is $$2a-1$$

cirpis
  • 1,868
  • I agree with this. What is it as a function of $b$? For which $a$ does it take that maximum? – Empy2 Jul 11 '14 at 15:04
1

E.g. try $a = 3$, $b = 5$. $3 + 2 > 2\times 3 - 2$.

Robert Israel
  • 448,999
1

If $b\ge 3$ is fixed, then $a$ mod $b$ + $b$ mod $a=a+(b$ mod $a)$. Since $b>a$, $b$ mod $a\le b-a$. So $a$ mod $b$ + $b$ mod $a \le a+b-a = b$. This upper bound of $b$ can be achieved by taking $a=b-1$. I guess this leaves the funny case of $b=2$. Then $a$ must be 1 (I am assuming that $a$ and $b$ are restricted to positive integers since we are modding by them). In this case $a$ mod $b$ + $b$ mod $a=1+0=1$, which would be the max in the $b=2$ case.

paw88789
  • 40,402