The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it:
- the 2 is found by adding the two numbers before it (1+1),
- the 3 is found by adding the two numbers before it (1+2),
- the 5 is (2+3),
- and so on!
<?php
if(isset($_POST['submit']))
{
$num1=$_POST['num1'];
$a = 0;$b = 1;$c=0;
echo "$a $b";
for($i=1; $i<= $num1-2; $a=$b, $b=$c, $i++){
echo $c = $a+$b;
echo " ";
}
//echo "<h5 style='text-align:center'> Factorial Of " . $num1 ." = " . $fact . " </h5>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Find Fibonacci Sequence</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-info" >
<div class="panel-heading">
<div class="panel-title">Find Fibonacci Sequence</div>
<div style="float:right; font-size: 80%; position: relative; top:-10px"></div>
</div>
<div style="padding-top:30px" class="panel-body" >
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
<form name="add" method="post" class="form-horizontal" role="form">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
<input type="text" class="form-control" name="num1" value="" placeholder="Enter Number" required>
</div>
<div style="margin-top:10px" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<input type="submit" value="Submit" name="submit" id="submit-btn" Class="btn btn-success" />
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>

0 Comments