170以上的阶乘 [英] Factorial of 170+
本文介绍了170以上的阶乘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每次我尝试获得171的阶乘时,我都会得到INF. 170工作正常.是否可以在脚本中获得171+的阶乘?如何? 我的功能:
everytime I try to get the factorial of 171, I get INF. 170 works fine. Is it possible to get the factorial of 171+ in a script? How? My function:
function factorial($n) {
if ($n == 0) return 1;
return $n * factorial($n - 1);
}
推荐答案
您将不得不使用 GNU MP 扩展名. PHP不提供任何用于高价值或高精度操作OOTB的工具.
You'll have to use BC Math or GNU MP extension. PHP doesn't provide any tools for high-values or high-precision operations OOTB.
这篇关于170以上的阶乘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文