• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Math Related / Calculate the nth root of a given number

Calculate the nth root of a given number

Calculate 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);

// Examples
nthRoot(32, 5); // 2

Source

https://www.30secondsofcode.org/js/s/nth-root

Math Related

Related Snippets:

  • Generate a random number in a given range with JavaScript
  • Check if the given number is even
  • Astrological Calculator
  • Take a number and return it in the specified currency formatting

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers