Difference between revisions of "CSC220 fibonacci4.php"
(Created page with '--~~~~ ---- <code><pre> <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, …') |
|||
Line 55: | Line 55: | ||
<br /> | <br /> | ||
− | [[ | + | [[Category:CSC220]][[Category:Php]] |
Latest revision as of 18:28, 19 September 2010
--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>