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
using System ; class GFG { public static bool isheptagonal ( int N ) { double n = ( 3 + Math . Sqrt ( 40 * N + 9 ) ) / 10 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( String [ ] args ) { int N = 7 ; if ( isheptagonal ( N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }