JavaScript的:计算一个数字的n次方根 [英] JavaScript: Calculate the nth root of a number

查看:2690
本文介绍了JavaScript的:计算一个数字的n次方根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一些使用JavaScript的n次方根,但我不明白的方式使用内置的数学对象来做到这一点。我俯瞰什么?
如果不是...

I'm trying to get the nth root of a number using JavaScript, but I don't see a way to do it using the built in Math object. Am I overlooking something?
If not...

有一个数学函数库,我可以使用具有这种功能?
如果不是...

Is there a math library I can use that has this functionality?
If not...

什么是最好的算法来做到这一点我自己?

What's the best algorithm to do this myself?

推荐答案

您可以使用这样的事情?

Can you use something like this?

Math.pow(n, 1/root);

如:

Math.pow(25, 1/2) == 5

这篇关于JavaScript的:计算一个数字的n次方根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆