Find n | func for calualtion ; for summation of square of first n - natural nos . ; summation of first n natural nos . ; return result ; Driver code
function seriesFunc ( n ) { let sumSquare = ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; let sumNatural = ( n * ( n + 1 ) / 2 ) ; return ( sumSquare + sumNatural + 1 ) ; } let n = 8 ; document . write ( seriesFunc ( n ) + " " ) ; n = 13 ; document . write ( seriesFunc ( 13 ) ) ;