略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 范例

2024-12-23

范例

示例 #1 Factorial function using GMP

<?php
function fact($x
{
    
$return 1;
    for (
$i=2$i <= $x$i++) {
        
$return gmp_mul($return$i);
    }
    return 
$return;
}

echo 
gmp_strval(fact(1000)) . "\n";
?>

This will calculate factorial of 1000 (pretty big number) very fast.

add a noteadd a note

User Contributed Notes 1 note

up
-11
fe at e dot com
4 years ago
If you ever need to use this, please see http://php.net/manual/en/function.gmp-fact.php

官方地址:https://www.php.net/manual/en/gmp.examples.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3