Triangular Matchstick Number In Python

Share on facebook
Share on twitter
Share on linkedin
Share on twitter
Share on tumblr

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

Leave a Comment

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