Apply for Zend Framework Certification Training

Php Questions






The Fibonacci series is a series of elements where, the previous two elements are added to get the next element, starting with 0 and 1. In this article, we will learn about how to generate a Fibonacci series in PHP using iterative and recursive way. Given a number n, we need to find the Fibonacci series up to the nth term.

 

function fabanocci($num){
    $num1 = 0;
    $num2 = 1;
    $counter = 0;
    while($counter < $num){
        echo ' '.$num1;
        $num3 = $num2 +$num1;
        $num1 = $num2;
        $num2 = $num3;
        $counter = $counter +1;
    }
    
}

fabanocci(10);

?>

< First Getting Started With CodeIgniter URL Routing >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top