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)
What about
# Returns a list of all divisors of n = a1^e1*a2^e2* ... *an^en
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
Ed Suominen wrote:
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
[Philp Smith]
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)
If the canonical factorization of N is the product of p_i**e_i, the
number of divisors
excellent - thanks
in the meantime I managed to write something myself which
a)works
b)looks reasonably elegant and pythonic
but
c) is recursive
d) requires a mainroutine and co-routine
I have a feeling if I analysed it it would prove to be relatively
inefficient as I'm sure it
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