For small numbers, trial division would work. Be sure to only divide by prime numbers. When you find one which divides your target, increment your counter and divide the target by that number as many times as it works. Then go on to the next prime. When the prime squared is larger than the target, you are done. The number of divisors is 2 times the product of the number of times each prime divided the target.
For large numbers you need to look into methods for factoring large numbers. You would want to start with a test to determine that the number is composite. If not, it has 2 divisors. Then try to divide the number by small primes. Then use one of the factoring algorithms such as the General Number Field Sieve to find factors. Don On May 11, 8:55 am, Harshit Gangal <harshit.gan...@gmail.com> wrote: > How can we calculate the number of divisors a number have in minimum time or > having minimum Time Complexity. > > -- > Harshit Gangal > Fourth Year Undergraduate Student > Dept. of Computer Science > JIIT, Noida , India -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.