Triangular Matchstick Number In Python

Share on facebook
Share on twitter
Share on pinterest

This Python program will help you to print the total number of a matchstick that is required to form a pyramid of matchsticks of x floors, where X represents the total number of floors.

Python Program To find Triangular Matchstick Number

def numOfSticks(x): 
     return (3 * x * (x + 1)) / 2



In the above program, we took X=5, the matchstick required will be three times of X-th triangular numbers, i.e., (3*X*(X+1))/2

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 *