[Coco] Project Euler and the Coco

Mark McDougall msmcdoug at iinet.net.au
Sat Nov 15 21:49:36 EST 2008


John wrote:

> 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...

> 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

A2 is used for *every* iteration of the B loop...

Regards,

-- 
|              Mark McDougall                | "Electrical Engineers do it
|  <http://members.iinet.net.au/~msmcdoug>   |   with less resistance!"



More information about the Coco mailing list