[Coco] Project Euler and the Coco

Darren A mechacoco at gmail.com
Sat Nov 15 01:53:08 EST 2008


On 11/14/08, Bill Barnes wrote:
>
> ...
>
> As far as precalc-ing A*A, would there not be an increase in speed to also
> precalc B*B and C*C?
>
> ...
>
>> > 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


No.  B*B and C*C have different values on each iteration of the inner
loop, and those expressions are only used once inside that loop.

Darren



More information about the Coco mailing list