Nth angle of a Polygon whose initial angle and per angle increment is given | Function to check if the angle is possible or not ; Angular sum of a N - sided polygon ; Angular sum of N - sided given polygon ; Check if both sum are equal ; Function to find the nth angle ; Calculate nth angle ; Return the nth angle ; Driver Code ; Checks the possibility of the polygon exist or not ; Print nth angle of the polygon
def possible ( N , a , b , n ) : NEW_LINE INDENT sum_of_angle = 180 * ( N - 2 ) NEW_LINE Total_angle = ( N * ( ( 2 * a ) + ( N - 1 ) * b ) ) / 2 NEW_LINE if ( sum_of_angle != Total_angle ) : NEW_LINE INDENT return False NEW_LINE DEDENT else : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT def nth_angle ( N , a , b , n ) : NEW_LINE INDENT nth = 0 NEW_LINE nth = a + ( n - 1 ) * b NEW_LINE return nth NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 3 NEW_LINE a = 30 NEW_LINE b = 30 NEW_LINE n = 3 NEW_LINE if ( possible ( N , a , b , n ) ) : NEW_LINE INDENT print ( nth_angle ( N , a , b , n ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " Not ▁ Possible " ) NEW_LINE DEDENT DEDENT