Given an integer N, the task is to check if it is a hexacontagon number or not.
Hexacontagon number is class of figurate number. It has 60 – sided polygon called hexacontagon. The N-th hexacontagon number count’s the 60 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few hexacontagonol numbers are 1, 60, 177, 352 …..
Examples:
Input: N = 60
Output: Yes
Explanation:
Second hexacontagon number is 60.Input: 35
Output: No
Approach:
- The Kth term of the hexacontagon number is given as K^th Term = (58*K^{2} – 56*K)/2
- As we have to check that the given number can be expressed as a hexacontagon 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 hexacontagon number.
Below is the implementation of the above approach:
// C++ implementation to check whether
// a number is a hexacontagon number or not
#include <bits/stdc++.h>
using namespace std;
// Function to check whether the
// number is a hexacontagon number
bool is_hexacontagon(int N)
{
float n = (56 + sqrt(464 * N + 3136)) / 116;
// Condition to check if the
// number is a hexacontagon number
return (n - (int)n) == 0;
}
// Driver Code
int main()
{
int i = 60;
// Function call
if (is_hexacontagon(i)) {
cout << "Yes";
} else {
cout << "No";
}
return 0;
}
Output:
Yes
