sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?
MRAB
python at mrabarnett.plus.com
Tue Jun 21 22:10:02 EDT 2011
On 22/06/2011 02:21, John Salerno wrote:
> ::sigh:: Well, I'm stuck again and it has to do with my get_factors
> function again, I think. Even with the slight optimization, it's
> taking forever on 20! (factorial, not excitement) :) It's frustrating
> because I have the Python right, but I'm getting stuck on the math.
>
> The problem:
>
> "What is the smallest positive number that is evenly divisible by all
> of the numbers from 1 to 20?"
>
You don't need factorials, just remember that each of the numbers can
be expressed as the product of a multiset of prime factors.
More information about the Python-list
mailing list