Program to print binomial expansion series | function to calculate factorial of a number ; function to print 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
< ? php function factorial ( $ n ) { $ f = 1 ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) $ f *= $ i ; return $ f ; } function series ( $ A , $ X , $ n ) { $ nFact = factorial ( $ n ) ; for ( $ i = 0 ; $ i < $ n + 1 ; $ i ++ ) { $ niFact = factorial ( $ n - $ i ) ; $ iFact = factorial ( $ i ) ; $ aPow = pow ( $ A , $ n - $ i ) ; $ xPow = pow ( $ X , $ i ) ; echo ( $ nFact * $ aPow * $ xPow ) / ( $ niFact * $ iFact ) , " " ; } } $ A = 3 ; $ X = 4 ; $ n = 5 ; series ( $ A , $ X , $ n ) ; ? >