Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Tribonacci Sequence in JavaScript

function tribonacci(signature,n){  
  for (var i = 0; i < n-3; i++) { // iterate n times
    signature.push(signature[i] + signature[i+1] + signature[i+2]); // add last 3 array items and push to trib
  }
  return signature.slice(0, n); //return trib - length of n
}
Comment

tribonacci sequence javascript

function tribonacci(s,n){
  var arr = [];
  for(var i=0; i<n; i++) {
    arr.push((i<3) ? s[i] : arr[i-1]+arr[i-2]+arr[i-3]);
  }
  return arr;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript assert example 
Javascript :: add item to list javascript 
Javascript :: get css custom property javascript 
Javascript :: how to upload file in material ui 
Javascript :: compose javascript 
Javascript :: run from build react 
Javascript :: strapi production build 
Javascript :: react native text input right 
Javascript :: hello world using alert 
Javascript :: angular load json file with httpclient 
Javascript :: node js throw error 
Javascript :: how to make hide/show btn in js 
Javascript :: order array of objects by id javascript 
Javascript :: javascript iterate over object keys and values 
Javascript :: jquery get element innertext 
Javascript :: regular expression javascript password strength 
Javascript :: react-router-dom 
Javascript :: javascript detect if element is scrolled 
Javascript :: joi string custom validation fuction 
Javascript :: read and update csv file in nodejs 
Javascript :: check scroll top height in react js 
Javascript :: prevent a page from refreshing in react 
Javascript :: Program for factorial of a number in javascript 
Javascript :: get value of hidden field jquery 
Javascript :: getx arguments 
Javascript :: chartjs hide text inside bar 
Javascript :: javascript select first n elements from array 
Javascript :: how many days old am i 
Javascript :: ant design table sort string perfectly 
Javascript :: how to catch and throw error js 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =