Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Fibonacci Series in javascript

function fibonacciSeries(number) {
    let fibo = [0, 1]
    for (var i = 2; i <= number; i++) {
        fibo[i] = fibo[i - 1] + fibo[i - 2];
    }
    return fibo;
}
console.log(fibonacciSeries(10))
//Output: [ 0, 1,  1,  2,  3,5, 8, 13, 21, 34, 55]
Comment

Fibonacci Series Program. in javascript

<script>
//Fibonacci Series using Recursion
    let n = 9;
     
    // function returns the Fibonacci number
    function fib(n) {
    if (n <= 1)
        return n;
    return fib(n-1) + fib(n-2);
}
  
    //function call
    document.write(fib(n));
//This code is contributed by Surbhi Tyagi
</script>
Comment

fibonacci series in javascript

// fibonacci series in javascript
const fibonacciSeries = (num) => {
    let arr = [];
    for(let i = 0; i <= num; i++) {
      if(i == 0 || i == 1){
        arr[i] = i;
      }else{
        arr[i] = arr[i - 1] + arr[i - 2];
      }
    }
    return arr;
}
console.log(fibonacciSeries(6)) //[ 0, 1,  1,  2,  3, 5, 8];
Comment

PREVIOUS NEXT
Code Example
Javascript :: $(this).text() in jquery return white space 
Javascript :: viewchild for ngfor 
Javascript :: react use same useState for multiple inputs 
Javascript :: return only specific attributes when making query mongoose 
Javascript :: create a html table dynamically using javascript 
Javascript :: how to append values to dropdown using jquery 
Javascript :: decode morse code js 
Javascript :: for range python javascript 
Javascript :: angular add a new line from component 
Javascript :: jquery $(document.on click 
Javascript :: js event preventdefault continue 
Javascript :: check if string contains substring javascript 
Javascript :: how to hide button in react 
Javascript :: discord.js button 
Javascript :: jquery get select name value 
Javascript :: post data from api using jquery ajax 
Javascript :: fetch data from asyncstorage react native 
Javascript :: js markdown to html 
Javascript :: string to jsonobject gson 
Javascript :: Write the JavaScript code to set the width of element to 50%; 
Javascript :: Angular version chrome console 
Javascript :: get the first word of a string javascript 
Javascript :: javascript change url 
Javascript :: javascript class inheritance 
Javascript :: error: cannot find module 
Javascript :: find object in array by property javascript 
Javascript :: JavaScript function that generates all combinations of a string. 
Javascript :: reduce() break 
Javascript :: check url with javascript 
Javascript :: react useeffect avoid initial render 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =