Program to check if N is a Octagonal Number | Python3 program for the above approach ; Function to check if N is a octagonal number ; Condition to check if the number is a octagonal number ; Driver Code ; Given number ; Function call
from math import sqrt NEW_LINE def isoctagonal ( N ) : NEW_LINE INDENT n = ( 2 + sqrt ( 12 * N + 4 ) ) / 6 ; NEW_LINE return ( n - int ( n ) ) == 0 ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 8 ; NEW_LINE if ( isoctagonal ( N ) ) : NEW_LINE INDENT print ( " Yes " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) ; NEW_LINE DEDENT DEDENT