Find the sum of n terms of the series 1 , 8 , 27 , 64 ... . | Function to calculate the sum ; Return total sum ; Driver code
function calculateSum ( n ) { return parseInt ( Math . pow ( n * ( n + 1 ) / 2 , 2 ) ) ; } var n = 4 ; document . write ( calculateSum ( n ) ) ;