Erdős-primes: Difference between revisions
Content added Content deleted
(Dialects of BASIC moved to the BASIC section.) |
(→{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic.) |
||
Line 286:
==={{header|Tiny BASIC}}===
Can't manage the stretch goal because integers are limited to signed 16 bit.
{{works with|TinyBasic}}
<syntaxhighlight lang="tinybasic"> LET P = 1▼
(Tom Pittman's) TinyBasic uses <code>;</code> instead of <code>,</code> for string concatenation in <code>PRINT</code>.
10 IF P > 2 THEN LET P = P + 2▼
IF P < 3 THEN LET P = P + 1▼
GOSUB 1000▼
40 IF P < 3
20 LET K = K + 1▼
70 IF A = 0
IF Z < 0 THEN GOTO 30▼
110 LET
130 GOSUB 1000
GOTO 20▼
140 IF
IF P > 2500 THEN END▼
170 LET C = C
1000 REM primality of Z by trial division, result is in A▼
200 GOTO 30
LET Y = 1▼
LET A = 0▼
IF Z = 2 THEN LET A = 1▼
1010 LET
1040 LET Y = Y
1050 IF (Z / Y) * Y = Z THEN RETURN
2000 REM factorial of K, result is in F▼
1080 RETURN
LET A = 1▼
2010 LET F = F*A▼
2040 LET A = A + 1
2050 GOTO 2020
3000 REM TODO: Simplify. K! can be calculated from (K - 1)!.</syntaxhighlight>
{{out}}
<pre>1 2
|