php教程

范例

Example #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.

User Contributed Notes

fe at e dot com 29-Dec-2017 03:08
If you ever need to use this, please see http://php.net/manual/en/function.gmp-fact.php

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788