tribonacci sequence in javascript

Solutions on MaxInterview for tribonacci sequence in javascript by the best coders in the world

showing results for - "tribonacci sequence in javascript"
Aimee
04 Jan 2019
1function tribonacci(signature,n){  
2  for (var i = 0; i < n-3; i++) { // iterate n times
3    signature.push(signature[i] + signature[i+1] + signature[i+2]); // add last 3 array items and push to trib
4  }
5  return signature.slice(0, n); //return trib - length of n
6}