Number of triangles after N moves | function to calculate number of triangles in Nth step ; Driver Code
< ? php function numberOfTriangles ( $ n ) { $ ans = 2 * ( pow ( 3 , $ n ) ) - 1 ; return $ ans ; } $ n = 2 ; echo numberOfTriangles ( $ n ) ; ? >