CSC220 fibonacci4.php
--D. Thiebaut 23:27, 19 September 2010 (UTC)
<html>
<head>
<title>Php variables</title>
<body>
<div>
<p>All the fibonacci terms up to the first one larger than 100
<P>
<?php
function display( $i, $f ) {
print "<li> fib( $i ) = <b>$f</b>\n";
}
$fib_1 = 1;
$fib_2 = 0;
$i = 1;
do {
$fib = $fib_1 + $fib_2;
// print "<li> fib[$i] = $fib";
if ( $fib <= 100 ) {
display( $i++, $fib );
}
$fib_2 = $fib_1;
$fib_1 = $fib;
} while ( $fib < 100 );
?>
</div>
</body>
</html>