Program for cube sum of first n natural numbers | Returns the sum of series ; Driven Program
function sumOfSeries ( n ) { x = 0 if ( n % 2 == 0 ) x = ( n / 2 ) * ( n + 1 ) else x = ( ( n + 1 ) / 2 ) * n return ( x * x ) } let n = 5 ; document . write ( sumOfSeries ( n ) ) ;