PHP PROGRAM TO GENERATE FIBONACCI SERIES - STUDENTSBLOG100 PHP TUTORIAL - Anna University Multiple Choice Questions

PHP PROGRAM TO GENERATE FIBONACCI SERIES - STUDENTSBLOG100 PHP TUTORIAL


This program is to display or generate Fibonacci series up to given input range. In the below given program, input variable is declared as $input_Num.

What is Fibonacci Series?
Addition of current number with preceding number is called as Fibonacci Series. Example, (0 + 1 = 1), (1 + 1 = 2), (2 + 1 = 3), (3 + 2 = 5)... and goes on. Result is 0,1,1,2,3,5....

Programming Logic:
  • Get the first number in variable $First_Num as 0 and second number in variable $Second_Num as 1. 
  • First add $Second_Num and $First_Num and store it in $result variable.
  • Now change $First_Num as $Second_Num and $Second_Num as $First_Num
  • Loop the process again and again up to input limit. 
Displaying Fibonacci Series PHP program:
Output:
1,2,3,5,8,13,21,34,55,89,

Click Here to get -- > Php Tutorials by Studentsblog100

1 comment:

  1. Interesting and useful article to me.. After reading this article i got more useful information about php .. thank you for sharing

    Php training with placement in chennai | Best php training in chennai

    ReplyDelete