O(sqrt(n)) solution


#1

vector Solution::allFactors(int A)
{
int square=(int)sqrt(A);
int s=ceil(sqrt(A));
vector ans;
for(int i=1;i<=square;i++)
{
if(A%i==0)
ans.push_back(i);
}
for(int i=ans.size()-1;i>=0;i–)
{
if(ans[i]!=s)
ans.push_back(A/ans[i]);
}
return ans;
}