Program to find Area of Triangle inscribed in N | Function to find the area of the polygon ; area of a regular polygon with N sides and side length len ; Function to find the area of a triangle ; area of one triangle in an N - sided regular polygon ; area of inscribed triangle ; Driver code
function area_of_regular_polygon ( n , len ) { let P = ( len * n ) ; let A = len / ( 2 * Math . tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; let area = ( P * A ) / 2 ; return area ; } function area_of_triangle_inscribed ( n , len ) { let area = area_of_regular_polygon ( n , len ) ; let triangle = area / n ; let ins_tri = ( triangle * 3 ) ; return ins_tri ; } let n = 6 , len = 10 ; document . write ( area_of_triangle_inscribed ( n , len ) . toFixed ( 3 ) ) ;