[Coco] Project Euler and the Coco

Art Flexser flexser at fiu.edu
Sat Nov 15 23:29:08 EST 2008


On Fri, 14 Nov 2008, John wrote:

> Hello all,
> 
> I'm sure by now many of you have seen Project Euler"at
> http://projecteuler.net/.
> 
> If not, they have math problems to solve.  One example is the 9th easiest:
> Find the product of a,b,c such that a^2 + b^2 = c^2 and a+b+b=1000.
> 
> I used my Coco2 to solve this problem in 11 and a half minutes using the
> high speed poke.  At the risk of flooding the list with BASIC code, I hope
> my short program here will spur comments and optimizations:
> 
> 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
> 
> For example, one optimization became clear after I had the answer.  As a
> hint, I could cut run time by about 40%...
> 

So, what was the 40%-saving hint?

Art





More information about the Coco mailing list