Program to get the Sum of series : 1 | Function to get the series ; Computing sum of remaining n - 1 terms . ; Driver Code
< ? php function Series ( $ x , $ n ) { $ sum = 1 ; $ term = 1 ; $ fct = 1 ; $ p = 1 ; $ multi = 1 ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) { $ fct = $ fct * $ multi * ( $ multi + 1 ) ; $ p = $ p * $ x * $ x ; $ term = ( -1 ) * $ term ; $ multi += 2 ; $ sum = $ sum + ( $ term * $ p ) / $ fct ; } return $ sum ; } $ x = 9 ; $ n = 10 ; $ precision = 4 ; echo substr ( number_format ( Series ( $ x , $ n ) , $ precision + 1 , ' . ' , ' ' ) , 0 , -1 ) ; ? >