例1 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";
?>

この例は、1000 の階乗(非常に大きな数です)を非常に高速に計算します。

add a note add a note

User Contributed Notes 1 note

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