Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0020/factor.dem
There are 2 other files named factor.dem in the archive. Click here to see a list.
100'  NAME--FACTOR
110'
120'  DESCRIPTION--FINDS THE PRIME FACTORIZATION OF A NUMBER.
130'
140'  SOURCE--BENNET VANCE, HANOVER ELEMENTARY SCHOOL
150'
160'  INSTRUCTIONS--TYPE "RUN" AND FOLLOW INSTRUCTIONS. THE
170'  PROGRAM WILL STOP IF THE NUMBER TO BE FACTORED IS 0.
180'
190'
200'  *  *  *  *  *  *    MAIN PROGRAM   *  *  *  *  *  *  *  *  *  *  *
210'
220 PRINT "THIS PROGRAM FINDS THE PRIME FACTORIZATION OF A NUMBER."
230 PRINT "IF YOU ASK IT TO FACTOR 0, IT WILL STOP."
240 PRINT
250 PRINT
260 PRINT "WHAT NUMBER IS TO BE FACTORED";
270 INPUT A
280 IF A<134217728 THEN 320
290 PRINT "SORRY!  THIS PROGRAM IS ONLY DESIGNED TO FACTOR NUMBERS"
300 PRINT "OF 8 DIGITS OR LESS!  YOU MAY TRY AGAIN--"
310 GOTO 240
320 LET D=A
330 PRINT
340 IF A=2 THEN 640
350 LET Q=0
360 IF A>0 THEN 380
370 STOP
380 LET C=2
390 GOSUB 430
400 FOR C=3 TO SQR(A) STEP 2
410 GOSUB 430
420 GOTO 590
430 LET B=0
440 IF A=C*INT(A/C) THEN 460
450 GOTO 490
460 LET A=A/C
470 LET B=B+1
480 GOTO 440
490 IF B<1 THEN 580
500 IF Q=1 THEN 570
510 LET Q=1
520 PRINT "THE PRIME FACTORS OF";D;"ARE:"
530 PRINT
540 PRINT "PRIME","MULTIPLICITY"
550 PRINT "-----","------------"
560 PRINT
570 PRINT C,B
580 RETURN
590 NEXT C
600 IF A=1 THEN 240
610 IF Q=0 THEN 640
620 PRINT A,1
630 GOTO 240
640 PRINT "THE NUMBER"A;"IS PRIME."
650 GOTO 240
660 END