Math question using variables: inverting a variable value

I want to streamline a process in which an Inn's price to sleep the night is inversely calculated against a variable that runs from 1-100 (a karma system). I'm just completely stumped on how to calculate it aside from 100 conditional branches for every possible value this variable can have ;_;

Essentially the Karma variable will range from 1-100 throughout the game, and I want an event command to take the value of the Karma variable and invert it - so when it is at say 25, another variable (InnPrice) will be set to 75. If Karma is 70, InnPrice becomes 30. If Karma is 100, InnPrice is 1.

I plan on customizing it further, as paying a single currency unit (or zero lol) for an inn stay is kinda goofy to me and I would prefer it follows some more math afterwards just to make it more realistic (like a flat +25 value added after all the math), but just getting to the point of having the variable inverted to begin with is muddling my brain. Anyone have a way to do this with some scripting or math magic?
n = Math.max(100 - n, 1);

100 becomes 1, 70 becomes 30, 1 becomes 99, 99 also becomes 1.
Anyone have a way to do this with some scripting or math magic?
the script for that would just be "Math.max(100-$gameVariables.value(x), 1)", replacing x with the id for the variable
Assuming variable 1 is used for karma and 2 stores the inn price:

JavaScript:
$gameVariables.setValue(2, Math.max(100 - $gameVariables.value(1), 1));
Inn Price = 100 - Karma.

You can set a another variable that will be the price of gold. Do a control variable command in the event and select script and add:
Math.max(100 - $gameVariables.value(1), 1)
Change the 1 in green to the variable ID of your karma variable.

Then in the inn keeper's event, change the gold check conditional for script to manually and put this:
$gameParty.gold() >= $gameVariables.value(2)
Change the 2 in green to the variable ID of your inn price variable.
Inn Price = 100 - Karma.
That...wow. Good LORD that is ridiculously easy I didn't even think of that lol

Also, Robro33's "Math.max(100-$gameVariables.value(x), 1)" should work as well.

thanks so much everyone!

Original thread: https://forums.rpgmakerweb.com/threads/math-question-using-variables-inverting-a-variable-value.165459/