Program to check if N is a Heptagonal Number | Python3 program for the above approach ; Function to check if N is a heptagonal number ; Condition to check if the number is a heptagonal number ; Given Number ; Function call
import math NEW_LINE def isheptagonal ( N ) : NEW_LINE INDENT n = ( 3 + math . sqrt ( 40 * N + 9 ) ) / 10 NEW_LINE return ( n - int ( n ) ) == 0 NEW_LINE DEDENT N = 7 NEW_LINE if ( isheptagonal ( N ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT