Q. Write a program to display the sum of the given series:
Sum=1 + (1+2) + (1+2+3) + (1+2+ 3.....n)
Answer :-
num = int(input("Enter the number:- ")) sum = 0 for i in range (2, num + 2): term = 0 for j in range (1, i): term += j print ("Term", (i - 1), ":", term) sum += term print ("Sum of", num, "term is", sum)
Output :-
Enter the number:- 3
Term 1 : 1
Term 2 : 3
Term 3 : 6
Sum of 3 term is 10
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )