Fibonacci3 in PHP
\n";
printf("%2d\t%19d\n", $n, $lo);
while ($hi > 0)
{
$n++;
if ($n > 46) break; # hack to stop loop: the while() test fails!
$ratio = $hi / $lo;
$s = sprintf("%2d\t%19d\t%19.15f\t%19.15f\n", $n, $hi, $ratio, $ratio - golden_ratio);
$s = preg_replace("/([0-9][0-9][0-9])([0-9][0-9][0-9])$/", "\\1_\\2", $s);
$s = preg_replace("/([0-9])([0-9][0-9][0-9])\t/", "\\1_\\2\t", $s);
for ($i = 1; $i <= 3; ++$i) # why, oh why, is there no replace-all-matches function?
$s = preg_replace("/([0-9])([0-9][0-9][0-9])_/", "\\1_\\2_", $s);
print $s;
$hi = $lo + $hi;
$lo = $hi - $lo;
}
print "\n";
?>