NOTE |
Use of internal subroutine branching. This program finds pythagorean triples. |
PRINT 'SOME PYTHAGOREAN TRIPLES ARE:' 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 |