I wrote some code to print the set of divisors but it is not expandable.
\input expl3-generic.tex
\def\divisors#1{%
\def\L{1}%
\def\M{#1}%
\def\x{2}%
\loop
\ifnum \fpeval{floor(#1/\x) = #1/\x} = 1\relax
\edef\L{\L, \x}
\ifnum \fpeval{\x = #1/\x} = 0 \edef\M{\fpeval{floor(#1/\x)}, \M} \fi
\fi
\edef\x{\fpeval{\x + 1}}%
\ifnum \fpeval{\x > sqrt #1} = 0%
\repeat
\L, \M}
\ExplSyntaxOn
\cs_new:Npn \fpeval #1
{ \fp_eval:n { #1 } }
\ExplSyntaxOff
$\divisors{625}$% Prints: 1, 5, 25, 125, 625
\bye
Could you imagine an expandable solution? I know that I could use LuaTeX for this, but programming in TeX is really interesting. ;)