Given an integer N, the task is to check if it is a Icosihexagonal number or not.
Icosihexagonal number is class of figurate number. It has 26 – sided polygon called Icosihexagon. The N-th Icosihexagonal number count’s the 26 number of dots and all other dots are surrounding with a common sharing corner and make a pattern. The first few Icosihexagonol numbers are 1, 26, 75, 148 …
Input: N = 26
Second icosihexagonal number is 26.
- The Kth term of the icosihexagonal number is given as
- As we have to check that the given number can be expressed as a icosihexagonal number or not. This can be checked as follows –
- Finally, check the value of computed using this formulae is an integer, which means that N is a icosihexagonal 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