Erdős-primes: Difference between revisions
→{{header|Tiny BASIC}}: Simplified and corrected. K! is calculated from (K - 1)!, not from the beginning. Now, there are displayed all 25 Erdős primes smaller than 2500 (previously, only 22).
(→{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic.) |
(→{{header|Tiny BASIC}}: Simplified and corrected. K! is calculated from (K - 1)!, not from the beginning. Now, there are displayed all 25 Erdős primes smaller than 2500 (previously, only 22).) |
||
Line 290:
<syntaxhighlight lang="basic">10 REM Erdős-primes
20 LET P = 1
30
40 IF P
50 IF P < 3 THEN LET
60
70 GOSUB 1000
70 IF A = 0 THEN GOTO 30▼
80
90 LET K =
100
110 LET
120
130
140
150 IF
160
170
180 IF
190 IF P > 2500 THEN END▼
200
230 GOTO 40
990 REM primality of Z by trial division, result is in A
Line 314 ⟶ 317:
1020 IF Z = 2 THEN LET A = 1
1030 IF Z < 3 THEN RETURN
1040 LET Y = Y +
1050 IF (Z / Y) * Y = Z THEN RETURN
1060 IF Y * Y < Z THEN GOTO 1040
1070 LET A = 1
1080 RETURN</syntaxhighlight>
▲2050 GOTO 2020
{{out}}
<pre>1 2
Line 337 ⟶ 330:
6 419
7 461
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 2351
24 2411
25 2437
</pre>
|