I have written a simple QBASI program that checks if a number is Prime.
But the program cannot handle numbers larger than 16 digits.
Is there a way I can use QBASI to check for Primes greater than 16 digits long?
My program below:
10 REM Prime Tester 7B
20 COLOR 15, 0, 0
30 DIM P AS _FLOAT
40 DIM N AS _FLOAT
60 INPUT "Number"; N
65 START = TIMER
70 IF N <= 0 GOTO 999
75 IF N = 1 THEN PRINT "Sorry! 1 is in the Unitary Group": GOTO 20
80 FOR P = 2 TO SQR(N)
90 IF N MOD P = 0 THEN PRINT "Composite": GOTO 130
100 NEXT P
110 COLOR 31, 0, 0
120 PRINT "Prime"
130 ELAPSED = TIMER - START
140 COLOR 15, 0, 0
150 PRINT "elapsed time is"; ELAPSED, "seconds"
160 BEEP
170 GOTO 20
999 END
Your help appreciated.
Regards
pya
But the program cannot handle numbers larger than 16 digits.
Is there a way I can use QBASI to check for Primes greater than 16 digits long?
My program below:
10 REM Prime Tester 7B
20 COLOR 15, 0, 0
30 DIM P AS _FLOAT
40 DIM N AS _FLOAT
60 INPUT "Number"; N
65 START = TIMER
70 IF N <= 0 GOTO 999
75 IF N = 1 THEN PRINT "Sorry! 1 is in the Unitary Group": GOTO 20
80 FOR P = 2 TO SQR(N)
90 IF N MOD P = 0 THEN PRINT "Composite": GOTO 130
100 NEXT P
110 COLOR 31, 0, 0
120 PRINT "Prime"
130 ELAPSED = TIMER - START
140 COLOR 15, 0, 0
150 PRINT "elapsed time is"; ELAPSED, "seconds"
160 BEEP
170 GOTO 20
999 END
Your help appreciated.
Regards
pya