Program for cube sum of first n natural numbers | Returns sum of first n natural numbers ; Driver code
< ? php function sumOfSeries ( $ n ) { $ x ; if ( $ n % 2 == 0 ) $ x = ( $ n / 2 ) * ( $ n + 1 ) ; else $ x = ( ( $ n + 1 ) / 2 ) * $ n ; return $ x * $ x ; } $ n = 5 ; echo sumOfSeries ( $ n ) ; ? >