Fibonacci sequence

Fibonacci sequence

Sequence # Value
F0 0
F1 1
F2 1
F3 2
F4 3
F5 5
F6 8
F7 13
F8 21
F9 34
F10 55
 

CODE FOLLOWS

<?php

// Include the header file
include('includes/header.php');

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Fibonacci sequence</title>
    <link rel="stylesheet" type="text/css" href="common.css" />
    <style type="text/css">
        th { text-align: left; background-color: #999; }
        th, td { padding: 0.4em; }
        tr.alt td { background: #ddd; }
    </style>
</head>
<body>

<h2>Fibonacci sequence</h2>

<table cellspacing="0" border="0" style="width: 20em; border: 1px solid
#666;">
    <tr>
        <th>Sequence #</th>
        <th>Value</th>
    </tr>
    <tr>
        <td>F<sub>0</sub></td>
        <td>0</td>
    </tr>
    <tr class="alt">
        <td>F<sub>1</sub></td>
        <td>1</td>
    </tr>

    <?php

    $iterations 
10;

    
$num1 0;
    
$num2 1;

    for ( 
$i=2$i <= $iterations$i++ )
    {
        
$sum $num1 $num2;
        
$num1 $num2;
        
$num2 $sum;
        
?>
        <tr<?php if ( $i != ) echo ' class="alt"' ?>>
            <td>F<sub><?php echo $i?></sub></td>
            <td><?php echo $num2?></td>
        </tr>
        <?php
    
}
    
?>
</table>
</body>
</html>

<?php
include('includes/footer.php');
?>