Post Reply 
What is the best BASIC Pocket Computer
04-16-2014, 12:47 AM
Post: #70
RE: What is the best BASIC Pocket Computer
(04-15-2014 10:03 PM)Guenter Schink Wrote:  Your factors program would be interesting to compare.

Here you go, prime factors in GW-BASIC. I haven't done any real performance tuning, apart from selecting an algorithm that's more efficient than "2 plus all the odd numbers".

Code:
5 DEFDBL X,F,M
10 INPUT "X=";X
15 ST=TIMER
20 M=INT(SQR(X))
30 F=0
40 DATA 2,1,2,2
50 FOR I=1 TO 4
60 READ S:GOSUB 500
70 NEXT I
100 IF X<=1 THEN 900
105 DATA 4,2,4,2,4,6,2,6
110 FOR I=1 TO 8
120 READ S:GOSUB 500
130 NEXT I
140 RESTORE 105
190 IF F>M THEN F=X:S=0:GOSUB 500
200 GOTO 100
500 F=F+S
510 IF X/F<>INT(X/F) THEN RETURN
520 X=X/F
530 M=INT(SQR(X))
540 PRINT F;
550 GOTO 510
900 ET=TIMER:PRINT
910 PRINT "Execution time: ";
920 PRINT USING "####.####";ET-ST;:PRINT "s"
930 END
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: What is the best BASIC Pocket Computer - Dave Britten - 04-16-2014 12:47 AM



User(s) browsing this thread: 1 Guest(s)