math - need divisors algorithm
Ed Suominen
ed-no at spam-eepatents.com
Thu Mar 31 02:28:21 EST 2005
Philp Smith wrote:
> Hi
>
> 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)
Is this compact enough? :-)
def properDivisors(N):
return [x for x in range(1,N-2) if not divmod(N,x)[1]]
---
Ed Suominen
Registered Patent Agent
Open-Source Software Author (yes, both...)
Web Site: http://www.eepatents.com
More information about the Python-list
mailing list