- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program for Triangular Matchstick Number
In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a number X which represents the floor of a matchstick pyramid, we need to display the total number of matchstick required to form a pyramid of matchsticks with x floors.
Now let’s observe the solution in the implementation below −
#function def numberOfSticks(x): return (3 * x * (x + 1)) / 2 # main() n=21 a=numberOfSticks(n) print(int(a))
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned about how we can make a Python Program for Triangular Matchstick Number
- C/C++ Program for Triangular Matchstick Number?
- C/C++ Program for the Triangular Matchstick Number?
- Program for triangular patterns of alphabets in C
- C++ Program for triangular pattern (mirror image around 0)
- C++ code to check triangular number
- Python Program for nth Catalan Number
- Python Program for n-th Fibonacci number
- Python Program for factorial of a number
- Python Program for Number of stopping station problem
- Program to print Lower triangular and Upper triangular matrix of an array in C
- C# Program to Illustrate Lower Triangular Matrix
- C# program to Illustrate Upper Triangular Matrix
- Java Program to display upper triangular matrix
- First triangular number whose number of divisors exceeds N in C++