Tribonacci Numbers | Javascript program to print first n Tribonacci numbers . ; driver function
function printTrib ( n ) { let dp = Array . from ( { length : n } , ( _ , i ) => 0 ) ; dp [ 0 ] = dp [ 1 ] = 0 ; dp [ 2 ] = 1 ; for ( let i = 3 ; i < n ; i ++ ) dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] + dp [ i - 3 ] ; for ( let i = 0 ; i < n ; i ++ ) document . write ( dp [ i ] + " " ) ; } let n = 10 ; printTrib ( n ) ;