Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Asen Bozhilov Newsgroups: comp.lang.javascript Subject: Re: sample scripts for solving euler problems Date: Fri, 2 Mar 2012 07:23:06 -0800 (PST) Organization: http://groups.google.com Lines: 27 Message-ID: <13347583.271.1330701787117.JavaMail.geo-discussion-forums@yner4> References: <496fa250-5efc-44f6-b88a-bca6dda08ec8@k4g2000yqa.googlegroups.com> NNTP-Posting-Host: 84.40.76.49 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1330702720 4448 127.0.0.1 (2 Mar 2012 15:38:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 2 Mar 2012 15:38:40 +0000 (UTC) In-Reply-To: <496fa250-5efc-44f6-b88a-bca6dda08ec8@k4g2000yqa.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.40.76.49; posting-account=7Fm93QoAAADJLfahesQYQvMxF-JssE8W User-Agent: G2/1.0 X-Received-Bytes: 1941 Xref: csiph.com comp.lang.javascript:12346 scripts examples =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0: > Got a web site setup for solving euler problems in python, perl, > ruby and javascript. >=20 > Feel free to give me any feedback, thanks. I looked at Project Euler Problem 1. Obviously you can solve the problem wi= th the formula of arithmetic progression sum:=20 =20 Even and without formula, you can solve it more elegant. The solution in Py= thon is on a line:=20 sum(range(3, 10, 3)) + sum(range(5, 10, 5)); #23 sum(range(3, 1000, 3)) + sum(range(5, 1000, 5)); #266333 JavaScript solution would be:=20 function multiples(x) { var sum =3D 0, i; for (i =3D 3; i < x; i +=3D 3) sum +=3D i; for (i =3D 5; i < x; i +=3D 5) sum +=3D i;=20 =20 return sum; } =20