Zgniotek Mc Zgniotek Mc - 1 year ago 83
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.


94 | 1.01
47.5 | 2
0.01 | 9500

Doesnt need to be exact, just rough.

Answer Source

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;


output = 100/input // if you need a tuning factor for your needs.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download