Given an integer N, the task is to check if N is a Heptagonal Number or not. If the number N is an Heptagonal Number then print “Yes” else print “No”.
Heptagonal Number represents Heptagon and belongs to a figurative number. Heptagonal has seven angles, seven vertices, and seven-sided polygon. The first few Heptagonal Numbers are 1, 7, 18, 34, 55, 81, …
Input: N = 7
Second heptagonal number is 7.
Input: N = 30
- The Kth term of the heptagonal number is given as
- As we have to check that the given number can be expressed as a Heptagonal Number or not. This can be checked as:
- If the value of K calculated using the above formula is an integer, then N is a Heptagonal Number.
- Else N is not a Heptagonal Number.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Program to check if N is a Centered heptagonal number
- Heptagonal number
- Centered heptagonal number
- Find the sum of the first N Centered heptagonal number
- Program to check whether a number is Proth number or not
- Program to check if N is a Pentadecagonal Number
- Program to check if N is a Octagonal Number
- Program to check if N is a Enneadecagonal Number
- Program to check if N is a Nonagonal Number
- Program to check if N is a Hexadecagonal Number
- Program to check if N is a Tetradecagonal Number
- Program to check if N is a Hendecagonal Number
- Program to check if N is a Octadecagon number
- Program to check Plus Perfect Number
- Program to check if N is a Decagonal Number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.