Last active
September 16, 2017 19:44
-
-
Save clemgrim/3d7f3e64ab51bdb04c3430d001c8bea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const steps = [ | |
{start: 60000, percent: .45}, | |
{start: 34000, percent: .37}, | |
{start: 20200, percent: .3}, | |
{start: 12450, percent: .24}, | |
{start: 0, percent: .19} | |
]; | |
function calc(x) { | |
for (let step of steps) { | |
if (step.start < x) { | |
return (x - step.start) * (1 - step.percent) + calc(step.start); | |
} | |
} | |
return x; | |
} | |
function getPercent(x) { | |
return 100 * (1 - calc(x) / x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment