Post Reply 
Sharp PC-1500A Compiler
12-03-2024, 08:00 PM
Post: #14
RE: Sharp PC-1500A Compiler
I wanted to try calculating prime numbers, but I missed the IF...GOSUB function. I added it to the compiler, and now it works as IF...GS. I tried the program in Basic and the ABC compiler. I set the search from 1 to 100. Basic took 94 seconds, and the compiler did it in 34 seconds.

10 INPUT "Enter lower limit: "; A
20 INPUT "Enter upper limit: "; B
30 PRINT "The prime numbers between "; A; " and "; B; " are:"
40 LET N = A
50 IF N > B THEN GOTO 120
60 LET F = 1
70 IF N < 2 THEN LET F = 0
80 LET D = 2
90 IF D > INT(SQR(N)) THEN GOTO 110
100 IF N / D = INT(N / D) THEN LET F = 0
105 LET D = D + 1
106 GOTO 90
110 IF F = 1 THEN PRINT N;" ";
115 LET N = N + 1
116 GOTO 50
120 END

0 N=A
1cIFN>BGO*
2 F=L
3 IFN<KGS+
4 D=K
5aR=N?X
6 R=RIX
7 IFD>RGO-
8 S=N/D
9 O=SIX
10 IFS=OGS+
11 D=D+L
12 GOa
13-IFF=LGSb
14 N=N+L
15 GOc
16+F=I
17 RET
18bPRN
19 WE
20 RET
21*STOP
22 END

For the compiler, you must manually enter the constants: A=1, B=100, K=2, L=1, I=0
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Sharp PC-1500A Compiler - Josef - 11-21-2024, 06:05 AM
RE: Sharp PC-1500A Compiler - Jeff_Birt - 11-21-2024, 03:34 PM
RE: Sharp PC-1500A Compiler - Josef - 11-22-2024, 05:49 AM
RE: Sharp PC-1500A Compiler - Josef - 11-27-2024, 08:25 PM
RE: Sharp PC-1500A Compiler - Josef - 11-30-2024, 06:31 PM
RE: Sharp PC-1500A Compiler - Josef - 12-03-2024, 07:45 PM
RE: Sharp PC-1500A Compiler - Josef - 12-01-2024, 12:32 PM
RE: Sharp PC-1500A Compiler - Thomas Klemm - 12-02-2024, 08:41 PM
RE: Sharp PC-1500A Compiler - toml_12953 - 12-02-2024, 11:49 PM
RE: Sharp PC-1500A Compiler - Josef - 12-02-2024, 10:35 PM
RE: Sharp PC-1500A Compiler - Thomas Klemm - 12-03-2024, 03:09 AM
RE: Sharp PC-1500A Compiler - toml_12953 - 12-03-2024, 03:41 AM
RE: Sharp PC-1500A Compiler - Thomas Klemm - 12-03-2024, 04:55 AM
RE: Sharp PC-1500A Compiler - Josef - 12-03-2024 08:00 PM
RE: Sharp PC-1500A Compiler - Josef - Yesterday, 06:57 AM



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