Zgniotek Mc Zgniotek Mc - 4 months ago 6
Javascript Question

The lower input the higher output

I want it so when user gives higher input, the output is smaller. I am making a gambling minigame, and this is what i need in table below. I dont know if there is any Math. function or something to make that.

INPUT | OUTPUT

94 | 1.01
47.5 | 2
0.01 | 9500


Doesnt need to be exact, just rough.

Answer

Your requirement seems to be an inverse proportion. That is, the output is inversely proportional to the input. A general equation that meets this behaviour is

output ∝ 1/x => output = k/x

So, a reciprocal of the input should do the trick. But, you might want to add a weighted factor to fine tune further.

For example,

output = 1/input;

or

output = 100/input // if you need a tuning factor for your needs.