Files
30-seconds-of-code/snippets/nth-root.md
2023-04-28 22:29:23 +03:00

373 B

title, type, tags, author, cover, dateModified
title type tags author cover dateModified
Nth root of number snippet
math
chalarangelo tree-roots 2021-01-06T22:47:48+02:00

Calculates the nth root of a given number.

  • Use Math.pow() to calculate x to the power of 1 / n which is equal to the nth root of x.
const nthRoot = (x, n) => Math.pow(x, 1 / n);
nthRoot(32, 5); // 2