4.018. The denominator of the geometric progression is $1 / 3$, the fourth term of this progression is $1 / 54$, and the sum of all its terms is 121/162. Find the number of terms in the progression.
Solution.

From the condition we have $\left\{\begin{array}{l}b_{4}=\frac{1}{54}, \\ S_{n}=\frac{121}{162}\end{array}\right.$.

Using formulas (4.6) and (4.11), we get

$$
\begin{aligned}
& b_{4}=b_{1} q^{3}=b_{1}\left(\frac{1}{3}\right)^{3} ; \frac{b_{1}}{27}=\frac{1}{54}, b_{1}=\frac{1}{2} ; \\
& S_{n}=\frac{b_{1}\left(1-q^{n}\right)}{1-q} ; \frac{\frac{1}{2}\left(1-\left(\frac{1}{3}\right)^{n}\right)}{1-\frac{1}{3}}=\frac{121}{162} \Rightarrow 243\left(3^{n}-1\right)=242 \cdot 3^{n} \Rightarrow \\
& \Rightarrow 3^{n}=243, n=5
\end{aligned}
$$

Answer: $n=5$.