Example 1: Triples

NOTE

Use of internal subroutine branching. This program finds pythagorean triples.

   

PRINT

   PRINT 'SOME PYTHAGOREAN TRIPLES ARE:'

   PRINT

   FOR A=1 TO 40

      AA = A*A

         AMINUS1 = A - 1

      FOR B=1 TO AMINUS1

         CC=AA+B*B

      GOSUB 50

         IF C = INT(C) THEN PRINT B,A,C

      NEXT B

   NEXT A

   STOP

*    SQUARE ROOT SUBROUTINE

50     C=CC/2

   FOR I=1 TO 20

      X=(C+CC/C)/2

      IF C = X THEN RETURN

      C=X

   NEXT I

   RETURN

END
See Also

Appendix C: mvBASIC Program Examples

General Coding Techniques

Example 2: Guess

Example 3: INV-INQ

Example 4: Format

Example 5: Lot-update

Example 6: Communications

Program