Home >> PHP >> Fibonacci series in PHP

Fibonacci series in PHP

$first=0;

$second=1;

$n=6;

for($i=0;$i<$n;$i++){

     if($i<=1){

         $next=$i;

    }else{

     $next=$first+$second;

     $first=$second;

     $second=$next;

   }

   echo $next;

}

return 0;

}

Post Your Comment

Next Questions
Fibonacci series using recursive
Print number 1 to 10 without loop
How can i sort array ascending order without function
How can i sort array descending order without function
How can find max difference between two elements from an array
How can find min difference between two elements from an array
How can find average from an array
How can find max element from an array
How can find min element from an array
How to connect mysql database with php
Remember password
How can find reverse string without function
How can find reverse word of string without function
How can print reverse string and show in array without function
How to insert data from mysql database
How to update data from mysql database
How to delete data from mysql database
How to list data from mysql database
error_reporting
error_reporting(E_ALL)
What is object oriented programming (oops)
What is class
What is object
What is static variable
What is static method

Copyright ©2022 coderraj.com. All Rights Reserved.