KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write Python code to find the sum of the given series:

1 + (1+2) + (1+2+3) + …………… + (1+2+3+……………+n)

Python Control Flow

2 Likes

Answer

n = int(input("Enter the value of n: "))
s = 0

for i in range(1, n+1):
    t = 0
    for j in range(1, i+1):
        t = t + j
    s = s + t

print("Sum of the series =", s)

Output

Enter the value of n: 6
Sum of the series = 56

Answered By

3 Likes


Related Questions