UNPKG
nth-root
Version:
latest (0.1.1)
0.1.1
0.1.0
Get the nth root of a number.
github.com/jonschlinkert/nth-root
jonschlinkert/nth-root
nth-root
/
index.js
12 lines
(10 loc)
•
255 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
/*! * nth-root <https://github.com/jonschlinkert/nth-root> * * Copyright (c) 2015, Jon Schlinkert. * Licensed under the MIT License */
module
.
exports
=
function
(
r, n
) {
var
num =
Math
.
pow
(
Math
.
abs
(r),
1
/(n ||
2
));
return
r <
0
? -num : num; };