[Tutor] Question on lists

Tim Peters tim_one@email.msn.com
Fri, 19 Mar 1999 04:30:50 -0500

The questions about recursion and ways to fiddle lists were covered well
already, so I'd just like to encourage you to think about other ways to
solve the problem.  Attached is a very similar algorithm that doesn't use
recursion.  Which is faster?  Which is clearer?  Which gives the right
answer <wink>?

not-rhetorical-questions-ly y'rs  - tim

def factor(n):
    a = []
    d = 2
    while d*d <= n:
        while n % d == 0:
            n = n / d
        d = d + 1
    if n > 1 or not a:
    return a