*4. If the function relationship $k=f(n)$ between natural numbers $n$ and $k$ is determined by the equation
$$
2\left(1+9+9^{2}+\cdots+9^{n-1}\right)=k(k+1)
$$

then the expression for $f(n)$ is
4. $k=f(n)=\frac{1}{2}\left(3^{n}-1\right)$ From the given, we have
$$
k(k+1)=\frac{2\left(9^{n}-1\right)}{9-1}=\frac{3^{n}-1}{2} \cdot \frac{3^{n}+1}{2},
$$

thus $k=f(n)=\frac{1}{2}\left(3^{n}-1\right)$.