Given a number N, the task is to check if N is a Octagonal Number or not. If the number N is an Octagonal Number then print “Yes” else print “No”.
Octagonal Number is the figure number that represent octagonal. Octagonal Numbers can be formed by placing triangular numbers on the four sides of a square. The first few Octagonal Numbers are 1, 8, 21, 40, 65, 96 …
Input: N = 8
Second octagonal number is 8.
Input: N = 30
- The Kth term of the octagonal number is given as
- As we have to check that the given number can be expressed as a Octagonal Number or not. This can be checked as:
- If the value of K calculated using the above formula is an integer, then N is a Octagonal Number.
- Else N is not a Octagonal Number.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Program to check if N is a Centered Octagonal Number
- Program to find Surface Area and Volume of Octagonal Prism
- Octagonal number
- Centered Octagonal Number
- Find the sum of the first N Centered Octagonal Number
- Program to check whether a number is Proth number or not
- Program to check if N is a Decagonal Number
- Program to check if N is a Octadecagon number
- Program to check if N is a Icosidigonal Number
- Program to check if N is a Myriagon Number
- Program to check if N is a Pentagonal Number
- Program to check if N is a Icosagonal Number
- Program to check if N is a Heptadecagonal Number
- Program to check if N is a Enneadecagonal Number
- Program to check if N is a Nonagonal Number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.