Consider two lamps with the same maximum brightness but: the first lamp has a dial accepting discrete values ranging from 0 (off) to 360 (full brightness), and the second lamp has a dial accepting discrete values from 0 to 100.
Given any value for the first dial, how do I calculate the closest new value for the first dial such there exists a value for the second dial that results in exactly the same brightness?
For example, a value of 40 for the first lamp can be reduced to 36 so that the equivalent value of the second lamp is exactly 10.
The relationship between the first lamp $a$ and the second lamp $b$ is:
$$ a = \frac{360}{100}b = 3.6b $$
Clearly, the lowest whole-number multiple of 3.6 is 18 ($36 \times 5$). Thus, we must round to the nearest compatible interval of 18, which we can compute like so:
$$f_b(a) = 18[\frac{a}{18}]$$
where $[x]$ is the round function.
This function satisfies the aforementioned requirements:
$$f_b(40) = 36$$ $$\frac{f_b(40)}{360} = \frac{\frac{f_b(40)}{3.6}}{100}$$