Difference between revisions of "CSC220 fibonacci5.php"

From dftwiki3
Jump to: navigation, search
Line 2: Line 2:
 
----
 
----
  
<source type="php">
+
<source type=php>
  
 
<html>
 
<html>

Revision as of 18:30, 19 September 2010

--D. Thiebaut 23:29, 19 September 2010 (UTC)


<html>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<PRAGMA NO-CACHE>
<head>
<title>Php variables</title>
<body>
<div>

<?php
function displayEven( $i, $f ) {
   if ( $f % 2 == 0 )
     print "fib[$i] = $f <br>";
}


$fibN = 1;
$fibN_1 = 1;

for ( $count=2; $count<10; $count++ ) {
  $temp = $fibN + $fibN_1;
  $fibN_1 = $fibN;
  $fibN   = $temp;
  displayEven( $count, $fibN );
}

?>
</div>
</body>
</html>