Number of triangles formed by joining vertices of n | Function to find the number of triangles ; print the number of triangles having two side common ; print the number of triangles having no side common ; initialize the number of sides of a polygon
function findTriangles ( n ) { var num = n ; document . write ( num + " " ) ; document . write ( num * ( num - 4 ) * ( num - 5 ) / 6 ) ; } var n ; n = 6 ; findTriangles ( n ) ;