Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/4sqrs.num
There are 2 other files named 4sqrs.num in the archive. Click here to see a list.
100'  NAME--4-SQRS
110'
120'  DESCRIPTION--WRITES INTEGERS AS SUMS OF 4 SQUARES.
130'
140'  SOURCE--UNKNOWN
150'
160'  INSTRUCTIONS--ENTER DATA IN LINE 400.
170'
180'  
190'  *  *  *  *   MAIN PROGRAM   *  *  *  *  *  *  *  *  *
200'
210 PRINT " N = A^2 + B^2 + C^2 + D^2"
220 PRINT
230 PRINT " N", " A", " B", " C", " D"
240 PRINT
250 READ N
260 IF N=-1 THEN 430
270 LET R = SQR(N)
280 FOR A = 0 TO R
290 FOR B = 0 TO N - A*A
300 FOR C = 0 TO N - A*A - B*B
310 IF A*A + B*B + C*C > N THEN 370
320 LET D = SQR(N - A*A - B*B - C*C)
330 IF D > INT(D) THEN 360
340 PRINT N,A,B,C,D
350 GOTO 250
360 NEXT C
370 NEXT B
380 NEXT A
390 GO TO 250
400 DATA 123, 321, 12345, 54321, 700, 2300
410 REM DATA IN 420 IS PART OF PROGRAM.
420 DATA -1
430 END