Read A Number N And Print The Natural Numbers Summation Pattern 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 natural numbers summation pattern” with the help of Python Programming Language.

Python Program To Read A Number N And Print The Natural Numbers Summation Pattern

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

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

    a=[]

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

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

        if(i<j):

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

        a.append(i)

    print("=",sum(a))

 print()

In the above basic python program, we took a number n and prints the summation of the natural number pattern.

 

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 *