Exemplos

Exemplo #1 Função fatorial usando 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";
?>

Este código irá calcular o fatorial de 1000 (um número grande) de forma muito rápida.

To Top