function factors(n)
    f = [1]
    for (p,e) in factor(n)
        l = length(f)
        s = 1
        for k = 1:e
            s *= p
            for indxf = 1:l
                push!(f, f[indxf]*s)
            end
        end
    end
    f
end

You can probably do even better by passing in a pre-allocated f and using
    empty!(f)
    push!(f, 1)
in the first two lines of factors.

--Tim

On Sunday, March 16, 2014 02:03:11 PM Stefan Schwarz wrote:
> less memory intensive indeed. ah! understand. you mean the relation between
> speed and memory consumption
> is your measure for better code (efficiency)
> 
> ok. fair enough. i was not concerning about memory usage, but i do agree
> with you perfectly.
> 
> thank you.
> 
> on the other hand. at the moment i am not concerned about memory usage but
> speed.
> 
> My aim is to be faster than Mathematica (no c-code etc. I could do this
> easily in Mathematica on my own...)
> 
> stefan

Reply via email to