Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
11
Task/Nth-root/JavaScript/nth-root.js
Normal file
11
Task/Nth-root/JavaScript/nth-root.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function nthRoot(num, nArg, precArg) {
|
||||
var n = nArg || 2;
|
||||
var prec = precArg || 12;
|
||||
|
||||
var x = 1; // Initial guess.
|
||||
for (var i=0; i<prec; i++) {
|
||||
x = 1/n * ((n-1)*x + (num / Math.pow(x, n-1)));
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue