KnowledgeBoat Logo
|

Informatics Practices

WAP to display the sum of the given series:

Sum = 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3…..n)

Python Control Flow

8 Likes

Answer

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

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

print("The sum of the series is:", sum)

Output

Enter the value of n: 4
The sum of the series is: 20

Answered By

2 Likes


Related Questions