PHP
How To Write a Program For Fibonacci Series in PHP

How To Write a Program For Fibonacci Series in PHP

By: SolutionsHint    33 views Updated: 22nd Jan, 2018
How To Write a Program For Fibonacci Series in PHP

Hello, everyone in this tutorial I will explain “How To Write a Program For Fibonacci series in PHP “. First two Fibonacci numbers are 0 and 1. After that, each number will be the sum of previous two numbers. Now we can see that third Fibonacci number is 1 ( sum of first two numbers 0 + 1), and fourth Fibonacci number will be the sum of third and second number ( 1 + 1 = 2 ) , and fifth Fibonacci number will be the sum of fourth and third number ( 2 + 1 = 3 ). The series will go to that infinity.

Here is the PHP script for printing first 20 Fibonacci numbers:

Output:

In this example I have created a series using for loop, you can also use while loop to create the same series.

About the Author

I am a professional blogger from my heart, I am going through all the possible ways that can help to audience. I am trying my best to write content that my readers will like me. I will really be happy when my readers will become more happy with my blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

Tweet
Share
+1
Share
0 Shares