Function by Robert Israel from the net:
restart; thefacts:= [seq(i!,i=2..20)]: getfacts:= proc(x::{algebraic,series}) local i; if type(x, {`+`,`*`,series}) then map(getfacts,x) elif type(x, fraction) then getfacts(numer(x))/getfacts(denom(x)) elif type(x,`^`) then getfacts(op(1,x))^op(2,x) elif type(x,negint) then -getfacts(-x) elif type(x,posint) then for i from 1 to 19 while irem(x, thefacts[i]) = 0 do od: if i = 1 then x elif thefacts[i-1] = x then ``(i)! else ``(i-1)!*getfacts(x/thefacts[i]) fi else x fi end; getfacts(series(sin(x),x));