Given an integer N, the task is to check if N is a Chiliagon Number or not. If the number N is a Chiliagon Number then print “Yes” else print “No”.
Chiliagon Number is class of figurate number. It has 1000 – sided polygon called Chiliagon. The N-th Chiliagon Number counts the 1000 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few Chiliagon Numbers are 1, 1000, 2997, 5992, …
Input: N = 1000
Second chiliagon number is 1000
- The Kth term of the Chiliagon Number is given as
- As we have to check that the given number can be expressed as a Chiliagon 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 a Chiliagon Number.
4. Else N is not a Chiliagon 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