Number of triangles in a plane if no more than two points are collinear | Function to find number of triangles in a plane . ; Formula to find number of triangle nC3 = n * ( n - 1 ) * ( n - 2 ) / 6 ; Driver code
function countNumberOfTriangles ( n ) { return n * ( n - 1 ) * ( n - 2 ) / 6 ; } var n = 4 ; document . write ( countNumberOfTriangles ( n ) ) ;