Python Program for Triangular Matchstick Number Improve Improve Like Article Like Save Share Report Given a number X which represents the floor of a matchstick pyramid, write a program to print the total number of matchstick required to form a pyramid of matchsticks of x floors. Examples: Input : X = 1 Output : 3 Input : X = 2 Output : 9 This is mainly an extension of triangular numbers. For a number X, the matchstick required will be three times of X-th triangular numbers, i.e., (3*X*(X+1))/2 # Python program to find X-th triangular # matchstick number def numberOfSticks(x): return (3 * x * (x + 1)) / 2 # main() print(int(numberOfSticks(7))) Output: 84 Please refer complete article on Triangular Matchstick Number for more details! Last Updated : 14 Mar, 2023 Like Article Save Article Previous Python Program for Find largest prime factor of a number Next Find one extra character in a string Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Triangular Matchstick Number Program to print Lower triangular and Upper triangular matrix of an array Program to print triangular number series till n Program to check if N is a Centered Triangular Number First triangular number whose number of divisors exceeds N Find the sequence number of a triangular number Python Program to check if matrix is lower triangular Python Program to check if matrix is upper triangular Program to check if matrix is lower triangular Program for triangular patterns of alphabets Like GeeksforGeeks Article Tags : DSA Python Programs