It may be worth noting that using gmp_strval can slow your script down a lot with large numbers.
This script for example, produces factorials in succession:
<?php
$start = microtime(TRUE);
$fact = gmp_init(1, 10);
for($i=1;$i<100000;$i++) { $fact = gmp_mul($fact, $i); if(microtime(TRUE)-$start>1) break;
}
printf("\$i = %d\n\$fact = %s\n", gmp_strval($fact, 10));
?>
My server calculates around about the 69,500th factorial on average every time. Uncommenting that gmp_strval line slows this process down dramatically, and only calculates about 5,000 factorials. This is about 14 times longer than before (this is consistent with allowing it to run for any number of seconds, not just 1).
Nitrogen.