Trailing-Edge
-
PDP-10 Archives
-
decuslib20-01
-
decus/20-0020/huprim.num
There are 2 other files named huprim.num in the archive. Click here to see a list.
100' NAME--HUGEPRIM
110'
120' DESCRIPTION--SEARCHES FOR PRIMES IN RANGE OF 1000.
130'
140' SOURCE--UNKNOWN
150'
160' INSTRUCTIONS--INPUT LEADING DIGITS UP TO 8. THE PROGRAM FINDS
170' ALL PRIMES IN THAT MILLENIUM. E.G. IF YOU INPUT 12345678,
180' IT WILL FIND ALL PRIMES OF UP TO 11 DIGITS OF THE FORM 12345678***.
190'
200'
210' * * * * * * * * MAIN PROGRAM * * * * * * * * * *
220'
230 DIM N(1000)
240 DIM P(168)
250 MAT N = ZER
260 FOR P = 2 TO 1000
270 IF N(P) < 0 THEN 340
280 LET K = K+1
290 LET P(K) = P
300 IF P > 31 THEN 340
310 FOR I = P TO 1000 STEP P
320 LET N(I) = -1
330 NEXT I
340 NEXT P
350 REM READ LEADING DIGITS.
360 PRINT "LEADING DIGITS (UP TO 8) OF RANGE TO BE SEARCHED";
370 INPUT A
380 IF A<134217728 THEN 410
390 PRINT "YOUR INPUT IS TOO BIG. TRY AGAIN--"
400 GOTO 360
410 LET S = SQR((A+1)*1E3)
420 PRINT
430 PRINT "LAST 3 DIGITS OF PRIMES:"
440 PRINT
450 MAT N = ZER
460 FOR K = 2 TO 168
470 LET P = P(K)
480 LET X = A - P*INT(A/P)
490 LET X = X*1E3
500 LET X = X - P*INT(X/P)
510 LET Y = P-X
520 IF Y <> 2*INT(Y/2) THEN 540
530 LET Y = Y+P
540 LET Z = (Y+1)/2
550 FOR I = Z TO 500 STEP P
560 LET N(I) = -1
570 NEXT I
580 NEXT K
590 REM TEST REMAINING NUMBERS.
600 FOR F = 1001 TO S STEP 2
610 GOTO 640
620 NEXT F
630 GOTO 720
640 LET X = A - F*INT(A/F)
650 LET X = X*1E3
660 LET X = F*(1+INT(X/F))-X
670 IF X > 1E3 THEN 620
680 IF X = 2*INT(X/2) THEN 620
690 LET Y = (X+1)/2
700 LET N(Y) = -1
710 GOTO 620
720 LET S = 0
730 FOR I = 1 TO 500
740 IF N(I) < 0 THEN 770
750 PRINT 2*I-1;
760 LET S = S+1
770 NEXT I
780 PRINT
790 PRINT
800 PRINT "THERE ARE"S"PRIMES IN THE RANGE."
810 STOP
820 END