Fibonacci series are number series,in which next number is the sum of previous two numbers.
Example: 0, 1, 1, 2, 3, 5, 8, 13, 21 etc
Let’s try to get 5 Fibonacci number series –
<?php
$a = 1;
$b = 1;
echo $a." ".$b." ";
for($i=1; $i<=5; $i++)
{
$c = $a+$b;
echo $c." ";
$temp = $b;
$b = $c;
$a = $temp;
}
Output :
1 1 2 3 5