Sum of series with alternate signed squares of AP | function to calculate series sum ; Driver code
function seiresSum ( n , a ) { return n * ( a [ 0 ] * a [ 0 ] - a [ 2 * n - 1 ] * a [ 2 * n - 1 ] ) / ( 2 * n - 1 ) ; } let n = 2 ; a = [ 1 , 2 , 3 , 4 ] ; document . write ( seiresSum ( n , a ) ) ;