Why does this PHP script crash?

EduardoV

New member
I did this script for the analysis of big multiples of 999.
The first function comes from the manual, and it works well. The second function is my creation. It works fine for small numbers, but it explodes when y = 5,000,000. Why?

Thanks, Eduardo.
<HTML>
<HEAD>
<TITLE>
Products
</TITLE>
</HEAD>
<BODY>
<?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";
/**/
function multiples($x,$y)
{
$return = 1;

for ($i=2; $i <= $y; $i++) {
$return = gmp_mul($i, $x);
}
echo ($i-1) . "\n";
return $return;
}
/**/

echo gmp_strval(multiples(999,500)) . "\n";
?>
<br>
<?php
echo gmp_strval(multiples(999,5000)) . "\n";
?>
<br>
<?php
echo gmp_strval(multiples(999,50000)) . "\n";
?>
<br>
<?php
echo gmp_strval(multiples(999,100000)) . "\n";
?>
<br>
<?php
echo gmp_strval(multiples(999,1000000)) . "\n";
?>
<br>


<?php
echo gmp_strval(multiples(999,5000000)) . "\n";
/**/

?>
</BODY>
</HTML>
 
Back
Top