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 Sequence in javascript

let fibo = [0, 1]
for (var i = 2; i <= 10; i++) {
    fibo[i] = fibo[i - 1] + fibo[i - 2];
}
console.log(fibo)
//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 :: javascript select all table rows 
Javascript :: react native linking phone call 
Javascript :: javascript string first letter lowercase 
Javascript :: how to copy text on clipboard in react 
Javascript :: jquery wrap inner text 
Javascript :: regex find img tag 
Javascript :: js get url params 
Javascript :: javascript getelementbyid disable 
Javascript :: get actual url in variable 
Javascript :: create slug in javascript 
Javascript :: remove item jquery 
Javascript :: node js load animation 
Javascript :: regular expression for indian mobile number 
Javascript :: regex valid jwt 
Javascript :: how will it look when there is a container inside a a row bootstrap 
Javascript :: alert confirm prompt javascript 
Javascript :: mui stack align verticaly center 
Javascript :: js map value in range 
Javascript :: change onclick attribute javascript 
Javascript :: how to update angular version 
Javascript :: select option in reactive forms 
Javascript :: js array into object 
Javascript :: change hover css javascript 
Javascript :: ejs partial pass value 
Javascript :: jquery find parent 
Javascript :: javascript rectangle collision 
Javascript :: how to save data i mongi db 
Javascript :: nodejs error _.isNull is not a function 
Javascript :: javascript video after play 
Javascript :: how to get greatest common divisor in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =