Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news-out.octanews.net!indigo.octanews.net!auth.beige.octanews.com.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.python Subject: Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)? References: <4e00faa9$0$49180$e4fe514c@news.xs4all.nl> <4e00fd85$0$49038$e4fe514c@news.xs4all.nl> <8b8c4bc8-7b26-4113-b95b-7eccbbd0e901@q30g2000yqb.googlegroups.com> <7x39j2ivcr.fsf@ruckus.brouhaha.com> <4c37d4e6-1c34-453c-8417-6b2c22e98451@l18g2000yql.googlegroups.com> Date: Tue, 21 Jun 2011 19:09:36 -0700 Message-ID: <7xd3i67h27.fsf@ruckus.brouhaha.com> Organization: Nightsong/Fort GNOX User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:jepzc1qovlICJYEr5VeRFWxRhFM= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 19 NNTP-Posting-Date: 21 Jun 2011 21:09:36 CDT X-Complaints-To: abuse@octanews.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8164 John Salerno writes: > It's frustrating because I have the Python right, but I'm getting > stuck on the math.... > "What is the smallest positive number that is evenly divisible by all > of the numbers from 1 to 20?" The answer is lcm [1,2,3, ... 20]. You can figure out how to implement lcm. The Euler problems are not really programming exercises. They are exercises in math and algorithms. Quite a lot of them involve thinking clever and fast ways to do stuff that would be trivial (but too slow) by brute force. In general, once you figure out the right algorithm, writing the code is easy. But you have to be fairly mathematically attuned, to have any chance of spotting the algorithm. If you want programming exercises that are less mathematical, there are some nice ones at rubyquiz.com. They are intended for Ruby but of course you can solve them in Python.