Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!not-for-mail From: jt@toerring.de (Jens Thoms Toerring) Newsgroups: comp.programming Subject: Re: Project Euler - add all natural numbers below 1000 Date: 26 May 2012 21:52:45 GMT Organization: Freie Universitaet Berlin Lines: 29 Message-ID: References: <4fbcc3ed$0$283$14726298@news.sunsite.dk> <26a153ab-d603-4734-803d-7c4c8bb1db50@googlegroups.com> X-Trace: news.uni-berlin.de BZceav2BZR+kz6kos8vWYwxMK7QxMjfsZtArXyxmu2xWccbxmSPAC9O0TW1KN2 X-Orig-Path: not-for-mail User-Agent: tin/1.9.3-20080506 ("Dalintober") (UNIX) (Linux/2.6.30-1-amd64 (x86_64)) Xref: csiph.com comp.programming:1625 bob wrote: > On Friday, May 25, 2012 4:29:06 AM UTC-5, Jens Thoms Toerring wrote: > > arnuld wrote: > > > AIM: To write a program to add all natural numbers below 1000 that are > > > multiples of 3 or 5. > > > > > WHAT I GOT: it works > > > > > Question-1: Look at the for loop, instead of looping for 1000 times and > > > checking the value inside, I am simply looping it 1000/3 = 333 times. Ist > > > that impressive ? > > > > > Question-2: Can it be improved ? [snipped] > > No loops involved, so computation time doesn't depend on the > > upper limit;-) > Bravo. Good job. Actually, Ike Naar posted the same solution two days earlier - I was just too inattentive to notice it:-( And your's at least showed the same basic idea, just using Gauss' formula had to be added;-) Regards, Jens -- \ Jens Thoms Toerring ___ jt@toerring.de \__________________________ http://toerring.de