Find sum of the series 1 | Function to calculate sum ; when n is odd ; when n is not odd ; Driver code
< ? php function solve_sum ( $ n ) { if ( $ n % 2 == 1 ) return ( $ n + 1 ) / 2 ; return - $ n / 2 ; } $ n = 8 ; echo solve_sum ( $ n ) ; ? >