Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
}
Source by www.codewars.com #
 
PREVIOUS NEXT
Tagged: #Tribonacci #Sequence #JavaScript
ADD COMMENT
Topic
Name
2+2 =