Calculating $e^{3x} \pmod{27}$ I am following some notes that say that $\exp(3x) = 1 + 3x + \frac{9}{2}x^2 + \frac{9}{2}x^3 = 1 +3x+18x^2+18x^3 \pmod{27}$
I can't understand this. Firstly why do we stop the expansion after 4 terms? And secondly I don't see why $ \frac{9}{2}x^2 + \frac{9}{2}x^3 = 18x^2+18x^3 \pmod{27}$
Could someone please explain it to me? I wish to follow the same method for $\log(1+5x) \pmod{5^4} $
Thanks in advance

$$e^{3x}=\sum_{k=0}^\infty\frac{(3x)^k}{k!}=1+3x+\frac{9x^2}2+\underbrace{\frac{9x^3}2}_{=\frac{27}{3!}}+\underbrace{27\left(\frac{x^4}{8}+\frac{3x^5}{40}+\ldots\right)}_{=0\pmod{27}}$$
and now check that
$$\frac12=2^{-1}=14\pmod{27}\implies \frac92=9\cdot14=18\pmod{27}$$
so we finally get
$$e^{3x}=1+3x+18x^2+18x^3\pmod{27}$$
