100 CLS 110 ' 120 PRINT "Homework. BASIC Program: Test For Prime" 130 PRINT 140 PRINT 150 PRINT 170 PRINT "To determine whether a number is prime, please enter a number greater than 0" 180 PRINT 190 PRINT 200 INPUT "Which number would you like to test"; X 210 220 IF X = 0 THEN PRINT "Error! Your number must be larger than 0": GOTO 900 230 IF X = 1 THEN PRINT "1 is neither a prime number nor a composite number, it is the number by which prime numbers are defined.": GOTO 900 240 IF X = 3 THEN PRINT "3 is a prime number.": GOTO 900 250 ' 260 LET Y = (X / 2) 270 IF Y = 1 THEN PRINT X; "is a prime number.": GOTO 900 280 IF Y = INT(Y) THEN PRINT X; "is not prime because it is divisible by 2.": GOTO 900 290 300 310 ' (The section above tests for even primes. If it's not '2' or divided by 2, it must be odd.) 320 ' (The next section loops thru all the odd numbers less than the number chosen) 330 ' 340 ' 350 LET Q = (X - 2) 360 FOR M = 3 TO Q STEP 2 370 LET P = (X / M) 380 IF P = INT(P) THEN PRINT X; "is not prime because it is divisible by"; M: GOTO 900 390 NEXT M 400 410 PRINT X; "is a prime number" 420 430 890 ' (End of program decision: yes,no or end) 900 PRINT 910 PRINT 920 PRINT 930 PRINT "Would you like to try again? (Y/N)" 940 INPUT A$ 950 IF A$ = "Y" THEN GOTO 180 960 PRINT 970 PRINT 980 PRINT "This completes our test of the emergency prime number testing system. If this had been an actual prime number emergency, you would have been directed to the nearest mathematics textbook." 990 PRINT "Thank you and good day." 999 END