Efficient PHP method to find sum of the elements of array that is halfway increasing and then halfway decreassing
< ? php function arraySum ( $ arr , $ n ) { $ x = ( $ n + 1 ) / 2 ; return ( $ arr [ 0 ] - 1 ) * $ n + $ x * $ x ; }