text: Program to print binomial expansion series | function to calculate factorial of a number ; function to prlet the series ; calculating the value of n ! ; loop to display the series ; For calculating the value of nCr ; calculating the value of A to the power k and X to the power k ; display the series ; Driver Code
code: function factorial ( n ) { let f = 1 ; for ( let i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } function series ( A , X , n ) { let nFact = factorial ( n ) ; for ( let i = 0 ; i < n + 1 ; i ++ ) { let niFact = factorial ( n - i ) ; let iFact = factorial ( i ) ; let aPow = Math . pow ( A , n - i ) ; let xPow = Math . pow ( X , i ) ; document . write ( ( nFact * aPow * xPow ) / ( niFact * iFact ) + " " ) ; } } let A = 3 , X = 4 , n = 5 ; series ( A , X , n ) ;