Google
 

Trailing-Edge - PDP-10 Archives - BB-D867D-BM - uetp/lib/factor.basic
There are 13 other files named factor.basic in the archive. Click here to see a list.
01000REM  NAME--FACTOR
01100REM
01200REM  DESCRIPTION--FINDS THE PRIME FACTORIZATION OF A NUMBER.
01300REM
01400REM  SOURCE--BENNET VANCE, HANOVER ELEMENTARY SCHOOL
01500REM
01600REM  INSTRUCTIONS--TYPE "RUN" AND FOLLOW INSTRUCTIONS. THE
01700REM  PROGRAM WILL STOP IF THE NUMBER TO BE FACTORED IS 0.
01800REM
01900REM
02000REM  *  *  *  *  *  *    MAIN PROGRAM   *  *  *  *  *  *  *  *  *  *  *
02100REM
02200 LET X=1
02300 LET W=0
02400 PRINT "THIS PROGRAM FINDS THE PRIME FACTORIZATION OF A NUMBER."
02500 PRINT "IF YOU ASK IT TO FACTOR 0, IT WILL STOP."
02600 PRINT
02700 IF W=0 THEN 3300
02800 IF 0.0=X-Z THEN 3200
02900 PRINT" "
03000 PRINT"? ERROR IN FACTORING. THE VALUE IS:";X;" IT SHOULD BE";Z
03100 GOTO 3300
03200 PRINT "FACTORS FOR ";Z;"CHECK AND MULTIPLY TO";X
03300 LET X=1
03400 LET W=1
03500 PRINT
03600 PRINT "WHAT NUMBER IS TO BE FACTORED";
03700 INPUT A
03800 LET Z=A
03900 IF A<134217728 THEN 4300
04000 PRINT "SORRY!  THIS PROGRAM IS ONLY DESIGNED TO FACTOR NUMBERS"
04100 PRINT "OF 8 DIGITS OR LESS!  YOU MAY TRY AGAIN--"
04200 GOTO 2600
04300 LET D=A
04400 PRINT
04500 IF A=2 THEN 7700
04600 LET Q=0
04700 IF A>0 THEN 4900
04800 STOP
04900 LET C=2
05000 GOSUB 5400
05100 FOR C=3 TO SQR(A) STEP 2
05200 GOSUB 5400
05300 GOTO 7100
05400 LET B=0
05500 IF A=C*INT(A/C) THEN 5700
05600 GOTO 6000
05700 LET A=A/C
05800 LET B=B+1
05900 GOTO 5500
06000 IF B<1 THEN 7000
06100 IF Q=1 THEN 6800
06200 LET Q=1
06300 PRINT "THE PRIME FACTORS OF";D;"ARE:"
06400 PRINT
06500 PRINT "PRIME","MULTIPLICITY"
06600 PRINT "-----","------------"
06700 PRINT
06800 PRINT C,B
06810 FOR V=1 TO B
06900 LET X=C*X
06910 NEXT V
07000 RETURN
07100 NEXT C
07200 IF A=1 THEN 2600
07300 IF Q=0 THEN 7700
07400 PRINT A,1
07500 LET X=A*X
07600 GOTO 2600
07700 PRINT "THE NUMBER";A;"IS PRIME."
07800 LET X=A
07900 GOTO 2600
08000 END