Count triangles required to form a House of Cards of height N | Function to find the number of triangles ; Driver Code ; Function call
function noOfTriangles ( n ) { return Math . floor ( n * ( n + 2 ) * ( 2 * n + 1 ) / 8 ) ; } var n = 3 ; document . write ( noOfTriangles ( n ) ) ;