![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrgeX9t3TqBf4-j0EDJy9QZQl6-7q_xQ41nyhb0yy0fON9s4T2rZ3RJBI14KVO_IFbe-LCmOFPUOYGzWSjpF31qhOCMht6GSbAEVUeLK7W0HljJknq2Y7tlTvjFOUzkee6yeOIJD8zRpo/s200/c0d23d2d6769e53e24a1b3136c064577-php_logo.png)
Procedure:
- We will collect the 1st number, 2 number and the length of series by HTML.
- Then we will print them serially.
- Add them. It will be the third number.
- Print the third number and generate the next number. Add this number with the previous sum.
- Use a loop till the length ends. It will generate the Fibonacci Sequence.
- Print them.
First generate the HTML to read data.
<form action='?' method='POST'> Enter the startig number: <input name="start" /><br/> Enter the second number: <input name="second" /><br/> Enter the series length: <input name="length" /><br/> <input type='submit' value='Generate Fibonacci'/> </form>
Now do the operations.
<?php if(isset($_POST['start'])) { $start = $_POST['start']; $length = $_POST['length']; $second = $_POST['second']; print "<u><b>The fibonacci series is:</b></u> " . $start ."+" . $second; $now = $start + $second; $sum = $now; for($i=3;$i<=$length;$i++) { print "+" . $now; $cache = $now; $sum = $sum + $now; $now = $now + $second; $second = $cache; } print "=$sum"; } ?>
Note: This procedure can be used in another programming languages. You have to just change the commands and operators their.
Happy programming!