GNU bc, 47 chars, including collecting input (need the GNU extensions for print
, else
and read
):
x=read();for(i=2;x>1;)if(x%i){i+=1}else{x/=i;i}
If you really want the x characters in the output, it's 64 chars:
x=read();for(i=2;x>1;)if(x%i){i+=1}else{x/=i;print i;if(x>1)"x"}
Also, note that using bc allows this to process numbers of arbitrary length.