Page 1 of 1
Fibonacci series : 1 10 2 9 3 8 4 7 5 6
Posted: Sat Nov 23, 2013 2:39 am
by pratikjajal
Hello,
Herebelow, I have mentioned the code of Fibonacci series : 1 10 2 9 3 8 4 7 5 6:
Code: Select all
$j=11;
for($i=1;$i<=5;$i++)
{
$j--;
if($j<=6)
{
}
echo "$i $j ";
}
Can we perform the same program with other loops? If yes, then describe.
Re: Fibonacci series : 1 10 2 9 3 8 4 7 5 6
Posted: Sat Nov 23, 2013 3:26 am
by requinix
Sure. for, foreach, while, do/while... They're all mostly interchangeable. They all have an initialization phase (set up variables), a conditional phase (whether to continue executing), and an advancement phase (what to do before the next loop starts). The series you're printing out can be done any one of a billion ways.
But that's not the Fibonacci series.
Re: Fibonacci series : 1 10 2 9 3 8 4 7 5 6
Posted: Sun Nov 24, 2013 8:47 pm
by Christopher
Re: Fibonacci series : 1 10 2 9 3 8 4 7 5 6
Posted: Sun Nov 24, 2013 10:15 pm
by Eric!
Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

Re: Fibonacci series : 1 10 2 9 3 8 4 7 5 6
Posted: Sun Nov 24, 2013 11:02 pm
by requinix
Party!

Re: Fibonacci series : 1 10 2 9 3 8 4 7 5 6
Posted: Sat Jun 18, 2016 9:02 am
by Prayag
Can we do this question with only one varible