Count the total number of triangles after Nth operation |  ; function 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; 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 ; } int main ( ) { int n = 10 ; cout << CountTriangles ( n ) ; return 0 ; }