Number of triangles after N moves | C ++ program to calculate the number of equilateral triangles ; function to calculate number of triangles in Nth step ; driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; int numberOfTriangles ( int n ) { int ans = 2 * ( pow ( 3 , n ) ) - 1 ; return ans ; } int main ( ) { int n = 2 ; cout << numberOfTriangles ( n ) ; return 0 ; }