Closest Multiple
6/7
To find the multiple of m closest to n, look at the two multiples that sandwich n:
q = trunc(n / m)gives one candidate,m × q, on the side toward zero- the next multiple away from zero, in the direction of
n, is the other candidate
Compare the distances |n − candidate| and keep the closer one. Problems like this reward you for naming the candidates first and only then comparing them. That's much clearer than trying to compute the answer in one clever expression.
Pay attention to the tie-breaking rule in the statement; ties are where most wrong answers come from.