I'm trying to verify the 3x + 1 problem, by running a PHP script online and evaluating all numbers.
I have an infinite loop running, but the server stops my loop when the value reaches about 35,000.
I'm guessing the termination is caused when my HTTP connection resets and the server is no longer serving my request.
I want to have it run as long as it can, eating up the server's resources if it wants to. How do I do it? Cronjobs?
Here's the script, the "End" is never printed.
class Collatz_Verify
{
public function Collatz_Verify()
{
// open output file
$file = 'verified_nums.txt';
$outFile = fopen($this->NUMBERS_FILENAME, 'a');
}
public function verify()
{
$num = 0;
while(1)
{
$num += 1;
# call collatz!!
if($this->collatz($num) == 1)
fwrite($this->outFile, $num);
}
print "ah, crap! End!";
}
public function collatz($num)
{
if ($num == 1)
return 1;
if (($num % 2) == 0)
return $this->collatz($num/2);
else
return $this->collatz((3*$num) + 1);
}
}
// Fire away!
$ver = new Collatz_Verify();
$ver->verify();
?>
set_time_limit?