I didn't code it already, but the most efficient way i can think of is by factoring and using the the generated Power set. Here's the basic idea.
Factoring
if a number is not prime, it can be factored into a product of primes. For instance:
4 = 2 * 2
6 = 2 * 3
66 = 2 * 3 * 11
22.308 = 2 * 2 * 3 * 11
Now let's look at the divisors of 66, which we can deduce from it's factored state. They are:
1
2
3
11
2 * 3 = 6
2 * 11 = 22
3 * 11 = 33
2 * 3 * 11 = 66
But notice you'll find a similar result if you calculate the powerset of {2, 3, 11}, which is
{ {}, {2}, {3}, {11}, {2, 3}, {2, 11}, {3, 11} , {2, 3, 11}}
Note the size of the resulting set is 8, the number of divisors of 66. There's a property of power sets which states that the size of a powerset is 2^n, where n is the size of the original set. So you should be able to find the number of divisors of a number by factoring it and passing it as power of 2.
But this does not work for all numbers. For instance, the same strategy won't work for 22.308, because the number 2 appears twice when factored.