[Coco] Project Euler and the Coco

Mark McDougall msmcdoug at iinet.net.au
Fri Nov 14 23:12:34 EST 2008


John wrote:

> 10 FOR A = 2 TO 333
> 20 FOR B = 334 TO 667
> 30 C = 1000 -A -B
> 40 IF C<A OR C<B THEN 60
> 50 IF A*A + B*B = C*C THEN 100
> 60 NEXT B,A
> 100 PRINT "A="A
> 110 PRINT "B="B
> 120 PRINT "C="C
> 130 PRINT "A  X  B  X  C  ="A*B*C

Not sure whether you mean algorithm optimisation, code optimisation, or both?

1. 20 FOR B=500-A TO 500+A gives result 40% quicker
2. pre-calc A*A at line 15 to run quicker

that's all I can see so far...

Regards,

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



More information about the Coco mailing list