So I have a range of numbers for this example I would say something like 0 to 25. Within this range if I get a number lets say 11, then for each number that between my goal I it weighs more depending on the range.
So in this case of the range being 0 to 25, and I have the number 11 and I am trying to point it out, but instead I point out 13 this would mean the weight of the number = 2.
Now what I would like to achieve is to have a modifier that modifies the weight according to number.
So as example that if you have 0 to 50, and you number was 11, and you chose 16 that the weight would also be 2.
I am usually pretty okay with basic mathematics, but I don't know what category this is in since I have no clue on where to start.
UPDATE: the chose number can also be lower then the given number. Each distance will still add weight, depending on range.
The relevant quantity to manipulate is $|x_0-x|$, the distance between the target $x_0$ and the selected number $x$.
The simplest possible solution is:
$$w = \lambda |x_0 - x|$$
with $\lambda$ a constant whose value may be chosen appropriately, for example in terms of the length of the interval $[a,b]$ to choose from, that is, $b-a$.
If you want the weight to increase faster farther from $x_0$, you can use higher powers of $|x_0-x|$, e.g. $|x_0-x|^2$. A combination is also possible:
$$w = \lambda |x_0-x| + \mu |x_0-x|^2$$
The possibilities are endless.