Background
When rounding down to the nearest 10's place, I would take the input number (x) and calculate it as follows:
//94 - (94 % 10) = 90
x - (x % 10) = input rounded down
Problem
What I am looking for is a way to take in a max number (e.g. 96) and round any lesser number, in intervals of 10, down to the closest '6' (e.g. 86, 76, 66, etc.)
Current Solution
The following calculation is what I have come up with, but I'm wondering if there is a better way and I'm just not thinking of it.
//71 + ((10 + ((71 % 10) - (96 % 10))) % 10) = 66
x + mod(10 + (mod(x, 10) - mod(96,10)), 10)
This solution does do what I want, but I am sure there is a much better (more simple/elegant) way to do this.
Let $m$ be your maximum (or any other number you want to use as key) and let $d = \operatorname{mod}(m, 10)$
Let $y = x - d$ and round $y$ down: $y' = y - \operatorname{mod}(y, 10)$.
Then the value you are after is $$\begin{align}x' &= y' + d \\&= y + d - \operatorname{mod}(y, 10)\\&=x - \operatorname{mod}(x - d, 10)\end{align}$$