Look at the pattern backwards: (3^n)+...(3^4)+(3^3)+(3^2)
Make a function that returns an int, and has a int parameter.
if "i" is greater than 2: return 3^i + the_function(i-1);,
else if its equal to 2: return 3^2;,
otherwise: else{ std::cout<<"error: input must be equal or greater than 2.\n"; return 0;}