Check if a number is an enneacontagon number

Updated

Given an integer N, the task is to check if it is a enneacontagon number or not.

enneacontagon number: is class of figurate number. It has 90 – sided polygon called enneacontagon. The N-th enneacontagon number count’s the 90 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few enneacontagonol numbers are 1, 90, 267, 532 …

Examples :

Input : N = 90 
Output :  Yes 
Explanation :  
Second enneacontagon number is 90. 

Input :  35 
Output :  No

Approach :

  1. The Kth term of the enneacontagon number is given as Kth Term = (88*K2 – 86*K) / 2
  2. As we have to check that the given number can be expressed as a enneacontagon number or not. This can be checked as follows –
N = (88*K2 - 86*K) / 2, so K = (86 + sqrt(704*N + 7396)) / 176
  1. Finally, check the value of computed using this formulae is an integer, which means that N is a enneacontagon number.

Implementation :

// C++ implementation to check that
// a number is a  enneacontagon number or not

#include <bits/stdc++.h>

using namespace std;

// Function to check that the
// number is a  enneacontagon number
bool isEnneacontagon(int N)
{
    float n
        = (86 + sqrt(704*N + 7396))
          / 176;

    // Condition to check if the
    // number is a  enneacontagon number
    return (n - (int)n) == 0;
}

// Driver Code
int main()
{
    int i = 90;

    // Function call
    if (isEnneacontagon(i)) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

Output :

Yes
Comment
Next tutorial
Mithlesh Upadhyay Published 1 Nov 2026 · 2 min read

Mithlesh Upadhyay is a Computer Science and AI expert from Madhya Pradesh with strong academic background (BE in CSE and M.Tech in AI) and over six years of experience in technical content development. He has contributed tech articles, led teams, and worked in Full Stack Development and Data Science. He founded the w3colleges.org portal for learning resources.

Related tutorials