0

Is it possible to count the divisors an integer has without just checking each one up to sqrt(n)? If not, is there at least a way to estimate or approximate how many divisors there are?

For example, 28 has six divisors (1, 2, 4, 7, 14, 28). 15 has four (1, 3, 5, 15). I want to, say, figure out how many divisors 242134575355654335549798955848371716626563756785 has, without counting all the way up to that (or at the very least make a guess and take it from there).

JesseTG
  • 2,025
  • 1
  • 24
  • 48

2 Answers2

2

If the prime factorisation of a number is known

N = p1^e1 * p2^e2 * ... * pn^en

the number of divisors is (e1+1)*(e2+1)* ... *(en+1)

For example 242134575355654335549798955848371716626563756785 = 5 * 48426915071130867109959791169674343325312751357 has 4 divisors

the number one higher 242134575355654335549798955848371716626563756786 = 2 * 101203 * 757790982862309619 * 1578643235504300177689649 has 16 divisors.

There are algorithms available that find the prime factorisation of a number much faster than trial division up to sqrt(n). For big numbers it will still take a while ...

Henry
  • 42,982
  • 7
  • 68
  • 84
  • But, again, the thing is how to get prime factorisation at first hand! – Am_I_Helpful Nov 15 '15 at 07:27
  • If there are quite a few small factors, prime factorization will go quickly. (Every divisor you find cuts down the problem size). It's only numbers that turn out to be prime, or the product of large primes, that take a lot of time. Your answer implies that there isn't any trick for counting the divisors without finding them. Are you fairly sure that there is no known algorithm? And if so, do you know if it's been proven that there isn't one? I mean, I don't think there is one, but I'm not a number theorist at all and there's tons of stuff I don't know. :P – Peter Cordes Nov 15 '15 at 08:34
  • @PeterCordes of course one can never be sure there is no trick, and I am not aware of a proof that none exists. – Henry Nov 15 '15 at 09:05
-1

There is way to factorization a number faster than sqrt(N) but if the n <=10^7 condition is true.The way uses Eratosthenes sieve.Here is a good explanation which also I learnt from. You can ask me for clarification.

Murat Akburak
  • 51
  • 1
  • 1
  • 12
  • That's actually not true, there are ways to factorize faster. – harold Nov 15 '15 at 09:06
  • You say there are ways to do it faster than logN or faster than sqrt(n) and the n<=10^7 condition has not to be true ? – Murat Akburak Nov 15 '15 at 10:00
  • Faster than sqrt(N), the n<=10^7 condition doesn't make much sense, that would force even the worst possible algorithm to become constant time. – harold Nov 15 '15 at 10:01
  • Uhm I usually hang out in competitive programming sites and I added that condition for make the algorithm run in 1s and not make it use much memory as a habit. Let's just remove the condition and say there is a nlogn way for factorization a number. Are we OK now :D – Murat Akburak Nov 15 '15 at 10:09