Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1625
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Project Euler - add all natural numbers below 1000 |
| Date | 2012-05-26 21:52 +0000 |
| Organization | Freie Universitaet Berlin |
| Message-ID | <a2d1ldFl67U1@mid.uni-berlin.de> (permalink) |
| References | <4fbcc3ed$0$283$14726298@news.sunsite.dk> <a291n2Fm87U2@mid.uni-berlin.de> <26a153ab-d603-4734-803d-7c4c8bb1db50@googlegroups.com> |
bob <bob@coolfone.comze.com> wrote:
> On Friday, May 25, 2012 4:29:06 AM UTC-5, Jens Thoms Toerring wrote:
> > arnuld <sunrise@invalid.address> 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
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
Project Euler - add all natural numbers below 1000 arnuld <sunrise@invalid.address> - 2012-05-23 11:03 +0000
Re: Project Euler - add all natural numbers below 1000 Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2012-05-23 13:30 +0200
Re: Project Euler - add all natural numbers below 1000 "H.J. Sander Bruggink" <sander.bruggink@uni-due.de> - 2012-05-23 14:11 +0200
Re: Project Euler - add all natural numbers below 1000 arnuld <sunrise@invalid.address> - 2012-05-23 12:44 +0000
Re: Project Euler - add all natural numbers below 1000 Ike Naar <ike@sverige.freeshell.org> - 2012-05-23 13:55 +0000
Re: Project Euler - add all natural numbers below 1000 bob <bob@coolfone.comze.com> - 2012-05-23 06:56 -0700
Re: Project Euler - add all natural numbers below 1000 jt@toerring.de (Jens Thoms Toerring) - 2012-05-25 09:29 +0000
Re: Project Euler - add all natural numbers below 1000 bob <bob@coolfone.comze.com> - 2012-05-25 06:26 -0700
Re: Project Euler - add all natural numbers below 1000 jt@toerring.de (Jens Thoms Toerring) - 2012-05-26 21:52 +0000
Re: Project Euler - add all natural numbers below 1000 "BartC" <bc@freeuk.com> - 2012-05-27 01:52 +0100
csiph-web