12. 已知等差数列 $\left\{a_{n}\right\}$ 中, $a_{1}+a_{4}+a_{7}=15, a_{2} a_{4} a_{6}=45$, 求此数列的通项公式.
$\because a_{1}+a_{7}=2 a_{4}, a_{1}+a_{4}+a_{7}=3 a_{4}=15$,

$\therefore a_{4}=5$

又 $\because a_{2} a_{4} a_{6}=45, \quad \therefore a_{2} a_{6}=9$,

即 $\left(a_{4}-2 d\right)\left(a_{4}+2 d\right)=9,(5-2 d)(5+2 d)=9$, 解得 $d= \pm 2$
若 $d=2, a_{n}=a_{4}+(n-4) d=2 n-3$;

若 $d=-2, a_{n}=a_{4}+(n-4) d=13-2 n$.