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))) |
chevron_right
filter_none
Output:
84
Please refer complete article on Triangular Matchstick Number for more details!
Recommended Posts:
- Python | Checking triangular inequality on list of lists
- Python Program for Efficient program to print all prime factors of a given number
- Python Program for How to check if a given number is Fibonacci number?
- Python Program to Find the Number Occurring Odd Number of Times
- Python Program for Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Python Program for Program to Print Matrix in Z form
- Python Program for Program to calculate area of a Tetrahedron
- Python Program for Program to find area of a circle
- Python Program for n-th Fibonacci number
- Python Program for n\'th multiple of a number in Fibonacci Series
- Python Program for Largest K digit number divisible by X
- Python Program for Smallest K digit number divisible by X
- Python program to count number of vowels using sets in given string
- Python Program for Number of stopping station problem
- Python Program for Print Number series without using any loop
- Python Program to Check Prime Number
- Python Program for Check if all digits of a number divide it
- Python Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Python Program for Find sum of even factors of a number
- Python Program for Find minimum sum of factors of number

