Given an integer N, the task is to check if it is a Icosidigonal Number or not. If the number N is an Icosidigonal Number then print “Yes” else print “No”.
The polygon has many gons, depends on their gonal number series. In mathematics, there are a number of gonal numbers and the Icosidigonal Number is one of them and these numbers have 22 -sided polygon(icosidigon). An Icosidigonal Number belong to the class of figurative number. They have one common dots points and other dots pattern is arranged in an n-th nested Icosidigon pattern.
The first few Icosidigonal numbers are 1, 22, 63, 124, 205, 306…
Input: N = 22
Second Icosidigonal number is 22.
1. The Kth term of the Icosidigonal number is given as
2. As we have to check that the given number can be expressed as an Icosidigonal Number or not. This can be checked as follows –
3. If the value of K calculated using the above formula is an integer, then N is an Icosidigonal Number.
4. Else N is not an Icosidigonal 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 mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.