math - need divisors algorithm
David Eppstein
eppstein at ics.uci.edu
Tue Apr 5 22:18:10 EDT 2005
> > Does anyone have suggested code for a compact, efficient, elegant, most of
> > all pythonic routine to produce a list of all the proper divisors of an
> > integer (given a list of prime factors/powers)
I have code for this in
<http://www.ics.uci.edu/~eppstein/numth/egypt/egypt.py>
(look for the function called, surprisingly, "divisors").
It's not very compact -- 155 lines from the start of the Pollard Rho
factorization (thanks to Kirby Urner) to the end of the divisors
function, but it's reasonably efficient even for largish numbers.
--
David Eppstein
Computer Science Dept., Univ. of California, Irvine
http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list