Program to print the series 1 , 3 , 4 , 8 , 15 , 27 , 50 â €¦ till N terms | Function to print the series ; Generate the ith term and print it ; Driver Code ; Function Call
function printSeries ( n , a , b , c ) { let d ; if ( n == 1 ) { document . write ( a + " " ) ; return ; } if ( n == 2 ) { document . write ( a + " " + b + " " ) ; return ; } document . write ( a + " " + b + " " + c + " " ) ; for ( let i = 4 ; i <= n ; i ++ ) { d = a + b + c ; document . write ( d + " " ) ; a = b ; b = c ; c = d ; } } let N = 7 , a = 1 , b = 3 ; let c = 4 ; printSeries ( N , a , b , c ) ;