Sum of the Series 1 + x / 1 + x ^ 2 / 2 + x ^ 3 / 3 + . . + x ^ n / n | Code to print the sum of the series ; Driver code
< ? php function sum ( $ x , $ n ) { $ i ; $ total = 1.0 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ total = $ total + ( pow ( $ x , $ i ) / $ i ) ; return $ total ; } $ x = 2 ; $ n = 5 ; echo ( sum ( $ x , $ n ) ) ; ? >