JavaScript: Calculate the nth root of a number

Nathan picture Nathan · Sep 5, 2011 · Viewed 45.3k times · Source

I'm trying to get the nth root of a number using JavaScript, but I don't see a way to do it using the built in Math object. Am I overlooking something?
If not...

Is there a math library I can use that has this functionality?
If not...

What's the best algorithm to do this myself?

Answer

Digital Plane picture Digital Plane · Sep 5, 2011

Can you use something like this?

Math.pow(n, 1/root);

eg.

Math.pow(25, 1/2) == 5