Computer Science, asked by GurJas3507, 11 months ago

Write Python script to calculate sum of following series :
s = (1) + (1+2) + (1+2+3) +…+ (1+2+3+…+n)

Answers

Answered by Anonymous
0

The python script to calculate the given series is:

def SeriesSum ( n ):

return sum ( [x*(x+1)/2 for x in range(1, n + 1) ] )

  • After specifying the "n" one can calculate the sum.
  • In the program, a function is defined named "SeriesSum".
  • The function is having the parameter "n".
  • After that, the sum is returned using list comprehension.

Similar questions