Read A Number N And Print The Series “1+2+…..+N= In Python

Share on facebook
Share on twitter
Share on pinterest

In this Basic Python Program, we will have a look at how to print the series 1+2+…..+N with the help of Python Programming Language.

Python Program To Read a Number N and Print the Series 1+2+…+N 

n=int(input("Enter a number: "))

a=[]

for i in range(1,n+1):

    print(i,sep=" ",end=" ")

    if(i<n):

        print("+",sep=" ",end=" ")

    a.append(i)

print("=",sum(a))

print()

Above program takes a number n and prints and computes the series “1+2+…+n=”.

 

Subscribe to our Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *