Forming triangles using points on a square | Function to return the count of possible triangles ; Driver code
function noOfTriangles ( n ) { var y = 4 * n ; return ( ( y * ( y - 2 ) * ( y - 1 ) ) - ( 4 * n * ( n - 2 ) * ( n - 1 ) ) ) / 6 ; } var n = 1 ; document . write ( noOfTriangles ( n ) ) ;