Given a number N, the task is to check if the number is a Triacontagonal number or not.
A Triacontagonal number is a class of figurate number. It has 30 – sided polygon called triacontagon. The N-th triacontagonal number count’s the 30 number of dots and all other dots are surrounding with a common sharing corner and make a pattern. The first few triacontagonol numbers are 1, 30, 87, 172 …
Input: N = 30
Second triacontagonal number is 30.
- The Kth term of the triacontagonal number is given as:
- As we have to check that the given number can be expressed as a triacontagonal 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 triacontagonal 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 DSA Live Classes