Given an integer N, the task is to check if N is a Hendecagonal Number or not. If the number N is an Hendecagonal Number then print “Yes” else print “No”.
Hendecagonal Number is a figurate number that extends the concept of triangular and square numbers to the decagon(11-sided polygon). The nth hendecagonal number counts the number of dots in a pattern of n nested decagons, all sharing a common corner, where the ith hendecagon in the pattern has sides made of i dots spaced one unit apart from each other. The first few hendecagonal numbers are 1, 11, 30, 58, 95, 141…
Input: N = 11
Second hendecagonal number is 11.
Input: N = 40
- The Kth term of the Hendecagonal Number is given as
- As we have to check that the given number can be expressed as a Hendecagonal 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 Hendecagonal Number.
- Else N is not a Hendecagonal 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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
In case you wish to attend live classes with industry experts, please refer Geeks Classes Live