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 triangles nC3 = n * ( n - 1 ) * ( n - 2 ) / 6 ; Driver code
< ? php function countNumberOfTriangles ( $ n ) { return $ n * ( $ n - 1 ) * ( $ n - 2 ) / 6 ; } $ n = 4 ; echo countNumberOfTriangles ( $ n ) ; ? >