编程学问
  • 文章
  • 问题
  • 读书
  • 关于
  • 登录
  • « 预定义常量
  • GMP 函数 »
  • PHP Manual
  • GMP
  • 范例

范例

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.

相关文章
php gmp 函数 calculates binomial coefficientphp gmp 函数 clear bitphp gmp 函数 compare numbersphp gmp 函数 calculates one s complementphp gmp 函数 divide numbersphp gmp 函数 divide numbers and get quotient and remainderphp gmp 函数 remainder of the division of numbersphp gmp 函数 convert gmp number to integerphp gmp 函数 inverse by modulophp gmp 函数 jacobi symbolphp gmp 函数 kronecker symbolphp gmp 函数 calculate gcdphp gmp 函数 legendre symbolphp gmp 函数 check if number is probably prime php gmp 函数 random numberphp gmp 函数 random numberphp gmp 函数 sets the rng seedphp gmp 函数 random numberphp gmp 函数 take the integer part of nth rootphp gmp 函数 bitwise xor
关注编程学问公众号
编程学问网 湘ICP备20001732号