Watch this Author's files
If you are using R2013a or later, make sure to change Line 3 from [b,m,n]=unique(factor(x)); to [b,m,n]=unique(factor(x),'last'); The default option of unique has changed from 'last' in R2012 to 'first' in R2013.
My hats off, John.
A three liner then, that will be fairly efficient.
f = x ./(1:ceil(sqrt(x)));
f = f(f==fix(f)).' ;
f = unique([f;x./f]);
For example, when x = 2^25, the two liner takes
Elapsed time is 114.624158 seconds.
While my three liner takes only
Elapsed time is 0.139695 seconds.