Re: math - need divisors algorithm

2005-04-07 Thread Peter Schorn
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

Re: math - need divisors algorithm

2005-04-05 Thread David Eppstein
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

Re: math - need divisors algorithm

2005-03-31 Thread Joal Heagney
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

Re: math - need divisors algorithm

2005-03-30 Thread Tim Peters
[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

Re: math - need divisors algorithm

2005-03-30 Thread Philp Smith
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

Re: math - need divisors algorithm

2005-03-30 Thread Ed Suominen
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