English 中文(简体)
系数170+
原标题:Factorial of 170+

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);
}
最佳回答

http://www.php.net/manual/en/book.bc.php rel=“noreferer”>BC Math 。 PHP为高价值或高精度业务提供任何工具。

问题回答
echo "1241018070217667823424840524103103992616605577501693185388951803611996075221691752992751978120487585576464959501670387052809889858690710767331242032218484364310473577889968548278290754541561964852153468318044293239598173696899657235903947616152278558180061176365108428800000000000000000000000000000000000000000"

确实,你的职责是罚款。 我认为,购买力平价缺乏这种精确性。 我看一看猪肉的价值(正确)

您的数值可能超过了32台轨道机器的最大双精确率(~10^308)170! 然而,根据这一点,171人! 规模更大。 最好的做法是,在答复时使用EboMike或Crozin建议的图书馆之一。

这比你能够使用32个轨道拥有的要多。 如果你在64轨计算机上操作同样的代码,那么它就应当工作。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签