Given an integer N, the task is to check if it is a Heptadecagonal Number or not. If the number N is an Heptadecagonal Number then print “Yes” else print “No”.
Heptadecagonal Number is class of figurate number. It has 17-sided polygon called heptadecagon. The N-th heptadecagonal number counts the seventeen number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few heptadecagonal numbers are 1, 17, 48, 94, 155, 231…
Input: N = 17
Second heptadecagonal number is 17.
Input: N = 30
- The Kth term of the heptadecagonal number is given as
- As we have to check that the given number can be expressed as a heptadecagonal number or not. This can be checked as follows –
- If the value of K calculated using the above formula is an integer, then N is a Heptadecagonal Number.
- Else N is not a Heptadecagonal Number.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
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.