Program to check if N is a Centered Octadecagonal number | C ++ implementation to check that a number is a Centered Octadecagonal number or not ; Function to check that the number is a Centered Octadecagonal number ; Implement the formula generated ; Condition to check if the number is a Centered Octadecagonal number ; Driver Code ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isCenteredOctadecagonal ( int N ) { float n = ( 9 + sqrt ( 36 * N + 45 ) ) / 18 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int n = 19 ; if ( isCenteredOctadecagonal ( n ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }