Trailing-Edge
-
PDP-10 Archives
-
decuslib20-01
-
decus/20-0020/chines.num
There are 2 other files named chines.num in the archive. Click here to see a list.
100' NAME--CHINESE
110'
120' DESCRIPTION--SOLVES N SIMULTANEOUS CONGRUENCES OF THE FORM:
130' A*X CONGRUENT TO B (MOD M).
140'
150' SOURCE--CHINESE REMAINDER THEOREM
160'
170' INSTRUCTIONS-- 620 DATA N
180' 630 START OF DATA IN TRIPLES A,B,M
190'
200'
210' * * * * * * MAIN PROGRAM * * * * * * * * *
220'
230 REM A(I)*X = B(I) MOD M(I), FOR I = 1 TO N
240 DIM M(100), A(100), B(100)
250 DIM X(100), N(100)
260 READ N
270 FOR I = 1 TO N
280 READ A(I), B(I), M(I)
290 PRINT A(I)"TIMES X CONGRUENT TO"B(I)"MOD"M(I)
300 FOR J = 1 TO M(I)
310 LET X = J*A(I)
320 IF X - M(I)*INT(X/M(I)) = 1 THEN 340
330 NEXT J
340 LET A = J*B(I)
350 LET A(I) = A-INT(A/M(I))*M(I)
360 NEXT I
370 PRINT
380 FOR I = 1 TO N
390 PRINT " X IS CONGRUENT TO"A(I)"MOD"M(I)
400 NEXT I
410 LET M = 1
420 FOR I = 1 TO N
430 LET M = M*M(I)
440 NEXT I
450 FOR I = 1 TO N
460 LET N(I) = M/M(I)
470 FOR J = 1 TO M(I)
480 LET X = J*N(I)
490 IF X - M(I)*INT(X/M(I)) = 1 THEN 530
500 NEXT J
510 PRINT "ERROR"
520 STOP
530 LET X(I) = J
540 NEXT I
550 LET X = 0
560 FOR I = 1 TO N
570 LET X = X + N(I)*X(I)*A(I)
580 NEXT I
590 LET X = X - M*INT(X/M)
600 PRINT
610 PRINT "***** X IS CONGRUENT TO"X"MOD"M
620 DATA 4
630 DATA 1,2,3,33,27,100,19,14,31,89,3,101
640 END