We want to calculate the sum of the first four terms of the following G.P.

There are two ways of solving this question. The first one would be to brute force calculate the first four terms and sum them(since it is a simple general term, it is totally possible to do it), or use the formula for the sum of the first n terms.
We can do both to be certain of our result.
Doing by brute force, we have the first 4 terms as:

The general formula to sum the first n terms is

Where n represents the amount of terms we want to sum, a_1 is the first term, and r is the base of our geometric progression.
For our problem, we have an n = 4, a_1 = 1 and r = 3. Plugging those values in our formula, we have

The sum of the first four terms of this progression is equal to 40.