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