home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / p4_9jb0.seq < prev    next >
Encoding:
Text File  |  1988-12-19  |  736 b   |  21 lines

  1.  
  2. \ Pythagorean Triples. Problem 6.              21:57JWB10/05/85
  3.   VARIABLE A    VARIABLE B      VARIABLE C      VARIABLE N
  4.   VARIABLE AA   VARIABLE BB     VARIABLE CC
  5. : .ABC  ( --   -- )
  6.         CR A @ 12 .R  B @ 12 .R  C @ 12 .R ;
  7. : TRIPLES ( --   -- )
  8.          25 1 DO   I A !  I DUP *  AA !
  9.                25 1 DO  I B ! I DUP *  BB !
  10.                      38 1 DO I C ! I DUP *  CC !
  11.                              AA @ BB @ + CC @ =
  12.                              IF .ABC THEN
  13.                     LOOP  LOOP
  14.   KEY?  ?LEAVE   ( any key escape )  LOOP ;
  15.  
  16. \ Problem 6: Modify to find all triples upto 100.  Can you make
  17. \ it run faster, using SQRT ? , without using variables?
  18. \ Modify so that triples are counted.
  19.  
  20.  
  21.