Number of triangles after N moves | C # program to find middle of three distinct numbers to calculate the number of equilateral triangles ; function to calculate number of triangles in Nth step ; Driver code
using System ; class Triangle { public static double numberOfTriangles ( int n ) { double ans = 2 * ( Math . Pow ( 3 , n ) ) - 1 ; return ans ; } public static void Main ( ) { int n = 2 ; Console . WriteLine ( numberOfTriangles ( n ) ) ; } }