Given an integer N, the task is to check if it is a icosikaioctagonal number or not.
An icosikaioctagonal number is class of figurate number. It has 28 – sided polygon called icosikaioctagon. The N-th icosikaioctagonal number count’s the 28 number of dots and all other dots are surrounding with a common sharing corner and make a pattern. The first few icosikaioctagonol numbers are 1, 28, 81, 160 …
Input: N = 28
Second icosikaioctagonal number is 28.
1. The Kth term of the icosikaioctagonal number is given as:
2. As we have to check that the given number can be expressed as an icosikaioctagonal number or not. This can be checked as follows –
3. Finally, check the value computed using these formulae is an integer, which means that N is an icosikaioctagonal number.
Below is the implementation of the above approach:
Time Complexity: O(1)
Auxiliary Space: O(1)
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