[Coco] Project Euler and the Coco
johnguin at hotmail.com
Sat Nov 15 19:29:23 EST 2008
At the risk of replying to a slightly older thread:
Wouldn't this code actually run slower because os the precalc in line 20?
An extra variable (A2) gets created only to be used one time - seems to me
it would be fractionally faster if that step was eliminated and A*A was
computed, used and discarded after line 40...
From: coco-bounces at maltedmedia.com [mailto:coco-bounces at maltedmedia.com] On
Behalf Of Mark McDougall
Sent: Saturday, November 15, 2008 4:53 AM
To: CoCoList for Color Computer Enthusiasts
Subject: Re: [Coco] Project Euler and the Coco
Mark McDougall wrote:
Even faster in BASIC...
10 FOR A=2 TO 333
20 A2=A*A; C=500
30 FOR B=500-A TO (1000-A)/2
40 IF A2+B*B=C*C THEN 100
60 NEXT B,A
100 ' print result
| Mark McDougall | "Electrical Engineers do it
| <http://members.iinet.net.au/~msmcdoug> | with less resistance!"
Coco mailing list
Coco at maltedmedia.com
More information about the Coco