Guest User

Untitled

a guest
May 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //_______________ Nth Root of a Number _____________//
  2. // Given two numbers x and n, calculate the (positive) nth root of x.
  3. // This means that being r = result, r^n = x; Examples
  4. // _______________________________________________________
  5. // _______________________________________________________
  6. // root(4, 2); // 2 (the square root of 4 is 2 , 2^2 = 4);
  7. // root(8, 3); // 2 (the cube root of 8 is 2 , 2^3 = 8);
  8. // root(256, 4); // 4 (the 4th root of 256 is 4 , 4^4 = 256);
  9. // root(9, 2); // 3 (the square root of 9 is 3 , 3^2 = 9)
  10.  
  11. function root(x,n){
  12. return Math.pow(x, 1/n);
  13. }
  14.  
  15. root(64,2);
Add Comment
Please, Sign In to add comment