Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathematical problem

I have the following function:

function getLevel(points)
{
  var level = -1 + Math.sqrt(4 + points/20);

  // Round down to nearest level
  return Math.floor(level);
}

The above function calculates the level of a player based on their points, my problem is that I need a function like this to calculate the points needed for a given level.

like image 905
coolboycsaba Avatar asked Jul 03 '26 14:07

coolboycsaba


1 Answers

The inverse of that function would be:

points = ((level + 1)**2 - 4) * 20

(where ** is the power operator).

like image 156
Greg Hewgill Avatar answered Jul 05 '26 15:07

Greg Hewgill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!