-
Notifications
You must be signed in to change notification settings - Fork 6
/
fibseq.php
66 lines (61 loc) · 1.13 KB
/
fibseq.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
$j = NULL;
$k = NULL;
function fib($end){
$j = 0;
$k = 1;
$a = "";
$b = "";
$c = array();
$d = 0;
$e = 1;
for ($i=0; $i < $end; $i++) {
if ($i == 0 ){
$j = 0;
}else{
$j = $j + $k;
}
$k = $j + $k;
$a = $j;
$b = $k;
$c[$d] = $a;
$c[$e] = $b;
$d += 2;
$e += 2;
}
return $c;
}
?>
<html>
<head>
<title></title>
</head>
<body>
<h1>Fib</h1>
<form method="POST" action=" ?">
<p>Number of Sequence: <input type="text" name="precision" /><input type="submit" value="Submit" name="Submit"/></p>
</form>
<?php
if(isset($_POST["precision"])){
$precision = $_POST["precision"];
$result = fib($_POST["precision"]);
echo '<table border=\'1\'>';
echo '<tr bgcolor="999FFF" style="text-align:center;">';
for ($i=0; $i < ($precision + 1); $i++) {
echo '<td>';
echo "<b>F</b><sub>" .$i ."</sub>";
echo '</td>';
}
echo '</tr>';
echo '<tr bgcolor="BBBBB" style="text-align:center;">';
for ($i=0; $i < $precision +1; $i++) {
echo '<td>';
echo $result[$i];
echo '</td>';
}
echo '</tr>';
echo '</table>';
}
?>
</body>
</html>