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