Algorithm to calculate the number of divisors of a given number

Posted by sker on Stack Overflow See other posts from Stack Overflow or by sker
Published on 2008-09-21T05:44:34Z Indexed on 2014/06/07 21:25 UTC
Read the original article Hit count: 391

Filed under:
|
|

What would be the most optimal algorithm (performance-wise) to calculate the number of divisors of a given number?

It'll be great if you could provide pseudocode or a link to some example.

EDIT: All the answers have been very helpful, thank you. I'm implementing the Sieve of Atkin and then I'm going to use something similar to what Jonathan Leffler indicated. The link posted by Justin Bozonier has further information on what I wanted.

© Stack Overflow or respective owner

Related posts about Performance

Related posts about algorithm