@cablecar said:
You can turn it off in your profile options.
Thanks, that's much better.
On an only pseudo-related note: I made a better-still implementation, but it's slightly larger... 50 lines or so. If you take my word that I have a divisorcount(x) function that tells you the factors of x and how many times they occur (example: divisorcount(150) => {2: 1, 3: 1, 5: 2} since 150 = 2 * 3 * 5 * 5), though, it's still short:
from euler_lib import divisorcount import operator nums = divisorcount(1) for x in range(1,20000): d = divisorcount(x) for p in d: nums[p] = max(nums.get(p, 0), d[p]) num = reduce(operator.mul, reduce(operator.add, [[k] * v for (k, v) in nums.iteritems()]))
Interestingly (or perhaps not) about a fifth of the time is spent in the final line, multiplying the factors of the answer to get the actual answer. I think if reduce() were smarter (didn't always evaluate LTR, for example) it could do a better job.
This being the case, I think it's time to expand the scope of this e-penis waving contest a bit. The largest number divisible by all integers <= a hundred thousand? A mere 3.692 seconds. Going up to a million takes 3m8.146s. Anyone have faster for a million in an interpreted language?