Count the total number of triangles after Nth operation |  ; Method to return the total no . of Triangles ; For every subtriangle formed there are possibilities of generating ( curr * 3 ) + 2 ; Changing the curr value to Tri_count ; driver code
class Gfg { public static int CountTriangles ( int n ) { int curr = 1 ; int Tri_count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { Tri_count = ( curr * 3 ) + 2 ; curr = Tri_count ; } return Tri_count ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( CountTriangles ( n ) ) ; } }