 April 08, 2020, 12:17:56 pm
 News: Want to see a specific Tutorial? ASK! # prime/factors

 Pages: Author Topic: prime/factors  (Read 360 times)
WB Brown
Newbie Posts: 1 « on: March 11, 2017, 04:43:12 pm »

10 REM PRIME/FACTORS
20 REM William B. Brown
30 REM 223 Harper Ridge Place
40 REM Antioch, TN 37013-3722
50 REM (573) 552-6822
60 REM COPYRIGHT July 1996, March 2017 by William B. Brown.
63 REM This program CANNOT be sold for any purpose without the
64 REM express written purpose of the author.
70 S\$ = "ONLY WHOLE NUMBERS GREATER THAN ZERO"
80 E\$ = "END NUMBER MUST BE EQUAL TO OR GREATER THAN THE START NUMBER"
90 CLS: PRINT: PRINT: PRINT "                               PRIMES AND FACTORS":
91 PRINT: PRINT "              COPYRIGHT July 1996, March 2017 by William B. Brown.":
92 PRINT "        This program CANNOT be sold for any purpose without the EXPRESS";
93 PRINT "                       written permission of the author.";
100 PRINT: PRINT "  (1) FIND THE PRIME FACTORS OF ONE NUMBER"
120 PRINT: PRINT "  (2) FIND THE PRIME FACTORS OF A RANGE OF NUMBERS"
140 PRINT: PRINT "  (3) TEST ONE NUMBER FOR PRIME"
150 PRINT: PRINT "  (4) FIND THE PRIMES IN A RANGE OF NUMBERS"
170 PRINT: PRINT "  (5) QUIT THE PROGRAM"
180 PRINT: PRINT: INPUT "TYPE THE NUMBER OF YOUR SELECTION"; Q
190 ON Q GOTO 810, 210, 960, 360, 1150
200 GOTO 90
205 REM FACTORS OF A RANGE OF NUMBERS
210 CLS: PRINT: PRINT: PRINT: PRINT "FIND THE FACTORS OF A RANGE OF NUMBERS"
220 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN  P  FOR PRINTER "; T\$
230 IF T\$ = "S" OR T\$ = "s" THEN PS = 0: GOTO 260
240 IF T\$ = "P" OR T\$ = "p" THEN PS = 1: GOTO 310
250 GOTO 210
260 GOSUB 550
270 CLS: PRINT: PRINT: PRINT: PRINT "FINDING ALL FACTORS OF THE NUMBERS BETWEEN"; SN; "AND"; EN; ".": PRINT: PRINT
290 GOSUB 610
300 PRINT "FINISHED": GOTO 770
310 GOSUB 550
330 LPRINT "FACTORS OF THE NUMBERS BETWEEN "; SN; " AND "; EN: LPRINT
335 PRINT "FACTORS OF THE NUMBERS BETWEEN "; SN; " AND "; EN: PRINT
340 GOSUB 1300
350 LPRINT: LPRINT "FINISHED": PRINT: PRINT "FINISHED": GOTO 770
355 REM TEST A RANGE OF NUMBERS FOR PRIMES
360 CLS: PRINT: PRINT: PRINT: PRINT "FIND THE PRIMES IN A RANGE OF NUMBERS"
370 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN  P FOR PRINTER "; T\$
380 IF T\$ = "S" OR T\$ = "s" THEN SP = 0: GOTO 410
390 IF T\$ = "P" OR T\$ = "p" THEN SP = 1: GOTO 460
400 GOTO 360
410 GOSUB 550
420 CLS: PRINT: PRINT: PRINT: PRINT "FINDING ALL PRIME NUMBERS BETWEEN"; SN; "AND"; EN; ".": PRINT: PRINT
440 GOSUB 700
450 PRINT: GOTO 770
460 GOSUB 550
480 LPRINT "ALL THE PRIME NUMBERS BETWEEN "; SN; " AND "; EN: LPRINT
485 PRINT "ALL THE PRIME NUMBERS BETWEEN "; SN; " AND "; EN: PRINT
490 GOSUB 700
500 LPRINT: LPRINT: LPRINT "FINISHED": PRINT: PRINT: PRINT "FINISHED": GOTO 770
510 IF FP <> 2 THEN PRINT FP; "*";: N = N / FP: RETURN
520 N = N / FP: IF N / FP = INT(N / FP) THEN PRINT FP; "*";: RETURN
530 IF N <> FP AND N <> 1 THEN PRINT FP; "*";: RETURN
540 PRINT FP;: RETURN
545 REM RANGE OF NUMBERS ENTRY
550 PRINT: PRINT: PRINT: INPUT "ENTER START NUMBER"; SN: N1 = SN
560 IF SN < 1 OR INT(SN) <> SN THEN PRINT: PRINT S\$: GOTO 550
570 PRINT: PRINT: PRINT: INPUT "ENTER ENDING NUMBER (< 10,000,000)"; EN
580 IF EN < 1 OR INT(EN) <> EN THEN PRINT: PRINT S\$: GOTO 570
590 IF EN < SN THEN: PRINT: PRINT E\$: GOTO 550
600 R = SN: RETURN
605 REM FACTOR FINDER-SCREEN
610 N = R: N1 = N: Z = 0
620 FOR FP = 2 TO SQR(N)
630 IF N / FP = INT(N / FP) THEN GOSUB 510: Z = 1: GOTO 620
650 NEXT: IF N <> 1 THEN PRINT N; "="; N1: GOTO 670
660 PRINT N; "="; N1
670 R = R + 1: IF R > EN THEN RETURN
680 GOTO 610
695 REM PRIME FINDER
700 N = R: N1 = N: IF N = 2 THEN GOTO 740
705 IF N = 1 THEN X = 1: NN = 1: GOTO 740
710 FOR FP = 2 TO SQR(N)
720 IF N / FP = INT(N / FP) THEN X = 1: GOTO 750
730 NEXT
740 IF N <> 1 THEN GOSUB 1200: GOTO 750
750 R = R + 1: IF R > EN THEN RETURN
760 GOTO 700
765 REM END OF OPTION SELECT
770 PRINT: PRINT: INPUT "TYPE Q TO QUIT OR M TO RETURN TO THE MAIN MENU"; Y\$
780 IF Y\$ = "Q" OR Y\$ = "q" THEN 1150
790 IF Y\$ = "M" OR Y\$ = "m" THEN 90
800 Y\$ = "": PRINT: GOTO 770
805 REM FACTORS OF ONE NUMBER
810 CLS: PRINT: PRINT: PRINT "FIND THE FACTORS OF A NUMBER"
820 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN OR P FOR PRINTER"; T\$
830 IF T\$ = "S" OR T\$ = "s" THEN GOTO 860
840 IF T\$ = "P" OR T\$ = "p" THEN GOTO 910
850 GOTO 810
860 GOSUB 1120
870 CLS: PRINT: PRINT: PRINT: PRINT "FINDING THE FACTORS OF THE NUMBER"
880 PRINT NN
890 GOSUB 610
900 PRINT: PRINT "FINISHED": GOTO 770
910 GOSUB 1120
920 LPRINT "FACTORS OF THE NUMBER"; NN: LPRINT
925 PRINT "FACTORS OF THE NUMBER"; NN: PRINT
940 GOSUB 1300
950 LPRINT: LPRINT "FINISHED": PRINT: PRINT "FINISHED": GOTO 770
960 CLS: PRINT: PRINT: PRINT: PRINT "TEST A NUMBER FOR PRIME": X = 0
970 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN OR P FOR PRINTER"; T\$
980 IF T\$ = "S" OR T\$ = "s" THEN GOTO 1010
990 IF T\$ = "P" OR T\$ = "p" THEN GOTO 1060
1000 GOTO 960
1010 GOSUB 1120
1020 CLS: PRINT: PRINT: PRINT "TESTING THE NUMBER"; NN; "FOR PRIME": PRINT: PRINT
1030 GOSUB 700: IF X <> 0 THEN PRINT NN; "NOT PRIME": GOTO 1050
1040 PRINT "IS PRIME"
1050 PRINT: R = NN: GOSUB 610: GOTO 770
1060 GOSUB 1120
1070 LPRINT "TESTING NUMBER"; NN; "FOR PRIME": LPRINT
1075 PRINT "TESTING NUMBER"; NN; "FOR PRIME": PRINT
1090 GOSUB 700: IF X <> 0 THEN LPRINT NN; "NOT PRIME": IF X <> 0 THEN PRINT NN; "NOT PRIME": GOTO 1110
1100 LPRINT NN; "IS PRIME": PRINT NN; "IS PRIME"
1110 LPRINT: LPRINT: LPRINT "FINISHED": PRINT: PRINT: PRINT "FINISHED": GOTO 770
1115 REM SINGLE NUMBER ENTRY
1120 PRINT: PRINT: PRINT: INPUT "ENTER NUMBER (< 10,000,000)"; NN: N1 = NN
1130 IF NN < 1 OR INT(NN) <> NN THEN PRINT: PRINT S\$: GOTO 1120
1140 R = NN: EN = NN: RETURN
1150 CLS: PRINT: PRINT: PRINT: PRINT "THANK YOU FOR USING FACTOR/PRIME FINDER":
1151 PRINT: PRINT " (C) JULY 1996, MARCH 2017 By William B. Brown":
1152 PRINT " WBBROWN11@GMAIL.COM":
1154 PRINT "        This program CANNOT be sold for any purpose without the EXPRESS";
1155 PRINT "                       written permission of the author.";
1200 IF SP = 0 THEN PRINT N; " ";: RETURN
1210 LPRINT N; " ";: PRINT N; " ";: RETURN
1295 REM FACTOR FINDER-PRINTER
1300 N = R: N1 = N: Z = 0
1320 FOR FP = 2 TO SQR(N)
1330 IF N / FP = INT(N / FP) THEN GOSUB 1510: Z = 1: GOTO 1320
1350 NEXT: IF N <> 1 THEN LPRINT N; "="; N1: PRINT N; "="; N1: GOTO 1370
1360 LPRINT N; "="; N1: PRINT N; "="; N1
1370 R = R + 1: IF R > EN THEN RETURN
1380 GOTO 1300
1510 IF FP <> 2 THEN LPRINT FP; "*";: IF FP <> 2 THEN PRINT FP; "*";: N = N / FP: RETURN
1520 N = N / FP: IF N / FP = INT(N / FP) THEN LPRINT FP; "*";: IF N / FP = INT(N / FP) THEN PRINT FP; "*";: RETURN
1530 IF N <> FP AND N <> 1 THEN LPRINT FP; "*";: IF N <> FP AND N <> 1 THEN PRINT FP; "*";: RETURN
1540 LPRINT FP;: PRINT FP;: RETURN

 Report Spam Logged

 Pages: