Fibonacci series in PHP

Learn how to print the Fibonacci series in PHP with this step-by-step tutorial. Explore PHP code examples and techniques for Fibonacci series output. Master PHP Fibonacci series printing today!

<?php

$n1 = 0;

$n2 = 1;

$limit = 10;

echo $n1.' '.$n2.' '; 

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

$n3 = $n2 + $n1;  

    echo $n3.' ';  

    $n1 = $n2;  

    $n2 = $n3;  

}

?>

OutPut:-

0 1 1 2 3 5 8 13 21 34 55 89 144  

Comments

Popular posts from this blog

Add Css And Js Files on Specific Page In laravel

Xpendy Pending

Laravel Join with two coloums