Trailing-Edge
-
PDP-10 Archives
-
decuslib20-01
-
decus/20-0020/pythag.num
There are 2 other files named pythag.num in the archive. Click here to see a list.
100' NAME--PYTHAG
110'
120' DESCRIPTION--GENERATES 86 PRIMITIVE TRIPLES (INTEGERS A,B,C
130' SUCH THAT A^2 + B^2 = C^2 AND A,B, AND C ARE RELATIVELY PRIME
140'
150' SOURCE--UNKNOWN
160'
170' INSTRUCTIONS--TYPE "RUN" AND FOLLOW INSTRUCTIONS.
180'
190'
200' * * * * * * MAIN PROGRAM * * * * * * * * * * *
210'
220 DIM X(100),Y(100),Z(100)
230 LET I = 0
240 LET Z(I) = 0
250 GOTO 340
260 LET M = A
270 LET N = B
280 LET M = M-N*INT(M/N)
290 IF M = 0 THEN 320
300 LET N = N-M*INT(N/M)
310 IF M*N <> 0 THEN 280
320 LET G = M+N
330 RETURN
340 PRINT "PRIMITIVE PYTHAGOREAN TRIPLETS:"
350 PRINT
360 PRINT
370 PRINT " A"," B"," C"
380 PRINT
390 FOR A = 1 TO 19
400 FOR B = A+1 TO 20 STEP 2
410 GO SUB 260
420 IF G > 1 THEN 520
430 LET X = 2*A*B
440 LET Y = B*B - A*A
450 LET Z = B*B + A*A
460 IF X < Y THEN 500
470 LET X1 = X
480 LET X = Y
490 LET Y = X1
500 GOSUB 580
510 LET I = I+1
520 NEXT B
530 NEXT A
540 FOR J = 1 TO I
550 PRINT X(J),Y(J),Z(J)
560 NEXT J
570 STOP
580 REM PLACE ON LIST ACCORDING TO SIZE OF Z.
590 FOR J = 0 TO I
600 IF Z > Z(J) THEN 630
610 LET I9 = J
620 GOTO 650
630 NEXT J
640 LET I9 = I+1
650 FOR J = I+1 TO I9+1 STEP -1
660 LET X(J) = X(J-1)
670 LET Y(J) = Y(J-1)
680 LET Z(J) = Z(J-1)
690 NEXT J
700 LET X(I9) = X
710 LET Y(I9) = Y
720 LET Z(I9) = Z
730 RETURN
740 END