Fibonacci Series in PHP using for loop
Last updated:6th Jul 2022
The Fibonacci series starts with 0, and 1. a next number of the Fibonacci series is generated by adding the previous two numbers.
program for fibonacci series
<?php
$a=0;
$b=1;
echo "fibonacci series for 10 element are:</br>";
echo $a.' '.$b;
for($num=0;$num<8;$num++)
{
$next=$a+$b;
echo ' '.$next;
$a=$b;
$b=$next;
}
output
fibonacci series for 10 element are: 0 1 1 2 3 5 8 13 21 34
Related Program
- Palindrome program in PHP
- Fibonacci Series in PHP by using for loop and HTML form
- Program to Check whether number is Even or Odd in PHP
- Factorial program in PHP by using for loop, while loop, and do-while loop
- Check user entered year is leap year or not in PHP
- Check whether a number is a prime number or not in PHP
- Reverse number program in PHP by using library function or without library function
- PHP program to greet the user based on time
- Write a PHP program to print the sum of digits