suppose that your number is 5040, and you factorise it
5040 = 24 * 32 * 5 * 7
The number of divisors will be
N_Divisors = 5 * 3 * 2 * 2 = 60 (note that I add 1 to every exponent)
To factorise you can do something like this
1 2 3 4 5 6 7 8
for(K = 0; K<prime.size() && prime[K] * prime[K] <= n; K++){
while(n%prime[K] == 0){
n/=prime[K];
//...
}
//...
}
//here n is 1 or a prime number
The idea was that primes is an array that have prime numbers (that you calculate before, maybe dynamical)
So your steps will be greater, because you don't test against every number.
What if your input is a prime number greater than 1000? You will return 1.