Program to check if N is a Nonagonal Number | C ++ program for the above approach ; Function to check if N is a is a Nonagonal Number ; Condition to check if the number is a nonagonal number ; Driver Code ; Given Number ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isnonagonal ( int N ) { float n = ( 5 + sqrt ( 56 * N + 25 ) ) / 14 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int N = 9 ; if ( isnonagonal ( N ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }