Program to get the Sum of series : 1 | Function to get the series ; Sum of n - 1 terms starting from 2 nd term ; Driver Code
function Series ( x , n ) { let sum = 1 , term = 1 , fct , j , y = 2 , m ; let i ; for ( i = 1 ; i < n ; i ++ ) { fct = 1 ; for ( j = 1 ; j <= y ; j ++ ) { fct = fct * j ; } term = term * ( - 1 ) ; m = term * Math . pow ( x , y ) / fct ; sum = sum + m ; y += 2 ; } return sum ; } let x = 9 ; let n = 10 ; document . write ( Series ( x , n ) . toFixed ( 4 ) ) ;