Function that counts the number of divisors of a natural number?

1.9k Views Asked by At

Let Function $f(n)$ be formally defined for natural numbers such that it gives number of distinct divisors of the number $n$ ($n$ and $1$ included) For example, $f (12)=6$, then what is a quick way to evaluate $f(48)$ or $f(2 ^{2013})$? Is there an explicit formula for such an $f(n)$ exist? if yes then what is it?

1

There are 1 best solutions below

8
On BEST ANSWER

It seems that by "parts" of the number you're referring to what's usually called its divisors. These are counted by the divisor function. An efficient way of finding its values can't be known, since this would yield an efficient way of determining whether a number is prime, and none such is known.

[Edit:]

Example calculations based on the prime factorizations of the numbers you asked about:

$48=2^4\cdot3^1$, so $\sigma_0(48)=(4+1)(1+1)=5\cdot2=10$. Also, $\sigma_0(2^{2012})=2012+1=2013$.

The general formula, as given in the Wikipedia article, is $\prod_i(a_i+1)$, where $a_i$ is the exponent of the $i$-th prime in the number's prime factorization.