How to scale numbers from one range to another range?

Solution 1:

The simplest way to take a range of $[1,20000]$ to $[1,10]$ is to subtract $1$, multiply by $\frac 9{199990}$ and add $1.$ If your division is integer divide, that will collapse many input values to the same output value. With only $10$ output values, there is no preventing that. If your division is floating point, $\frac 1{2000}$ is not small, so you can still see differences.