  Let $R$ be a gcd-domain (for example let $R$ be a unique factorization
domain), and let $(a_n)_{n\geqslant1}$ be a sequence of nonzero elements in
$R$. We prove that $\gcd(a_n,a_m)=a_{\gcd(n,m)}$ for all $n,m\geqslant1$ if and
only if $$a_n=\prod\limits_{d\mid n} c_d\quad\mbox{for} \ n\geqslant1, $$ where
$c_1=a_1$ and
$c_n=\mbox{lcm}(a_1,a_2,\dots,a_n)/\mbox{lcm}(a_1,a_2,\dots,a_{n-1})$ for
$n\geqslant2$. All equalities with gcd and lcm are determined up to units of
$R$.
