### Total Number Of Divisors

Posted:

**Sat Apr 21, 2012 7:28 pm**how to know fastly the number of divisors?

please give me a c++ example.

please give me a c++ example.

The UVa Online Judge board

https://uva.onlinejudge.org/board/

https://uva.onlinejudge.org/board/viewtopic.php?f=22&t=70861

Page **1** of **1**

Posted: **Sat Apr 21, 2012 7:28 pm**

how to know fastly the number of divisors?

please give me a c++ example.

please give me a c++ example.

Posted: **Sun Apr 22, 2012 10:27 pm**

You can count the devisors between 1 and sqrt(n) and double it.

Then if n is a square number, subtract 1 from the result.

Then if n is a square number, subtract 1 from the result.

Posted: **Mon Apr 23, 2012 5:25 am**

Is there any faster way?

Posted: **Mon Apr 23, 2012 7:55 am**

Find the prime factorization first.

Posted: **Mon Apr 23, 2012 8:40 pm**

Doesn't it take time as much as Seyedparsa's algorithm?

Posted: **Mon Apr 23, 2012 9:56 pm**

Checking only primes is faster than checking every integer.

Posted: **Sat Aug 18, 2012 8:01 pm**

If the prime factorization of an integer is

p1^x1 * p2^x2 * p3^x3 * ... * pn^xn , where, p1, p2, ..., pn are primes,

then the number of divisors is

(x1 + 1) * (x2 + 1) * (x3 + 1) * ... * (xn + 1)

p1^x1 * p2^x2 * p3^x3 * ... * pn^xn , where, p1, p2, ..., pn are primes,

then the number of divisors is

(x1 + 1) * (x2 + 1) * (x3 + 1) * ... * (xn + 1)