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
function possible ( N , a , b , n ) { let sum_of_angle = 180 * ( N - 2 ) ; let Total_angle = Math . floor ( ( N * ( ( 2 * a ) + ( N - 1 ) * b ) ) / 2 ) ; if ( sum_of_angle != Total_angle ) return false ; else return true ; } function nth_angle ( N , a , b , n ) { let nth = 0 ; nth = a + ( n - 1 ) * b ; return nth ; } let N = 3 , a = 30 , b = 30 , n = 3 ; if ( possible ( N , a , b , n ) ) document . write ( nth_angle ( N , a , b , n ) ) ; else document . write ( " " ) ;