Cullen and Woodall numbers: Difference between revisions
Content deleted Content added
Cullen and Woodall numbers in various dialects BASIC (Gambas, Run BASIC and XBasic) |
Cullen and Woodall numbers in Tiny BASIC |
||
Line 310: | Line 310: | ||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |
||
==={{Header|Tiny BASIC}}=== |
|||
<syntaxhighlight lang="qbasic">REM Rosetta Code problem: https://rosettacode.org/wiki/Cullen_and_Woodall_numbers |
|||
REM by Jjuanhdez, 03/2023 |
|||
REM TinyBasic does not support values greater than 32767 |
|||
PRINT "First 11 Cullen numbers:" |
|||
LET N = 0 |
|||
LET I = 1 |
|||
10 IF I = 12 THEN GOTO 20 |
|||
GOSUB 50 |
|||
LET N = (I*R) +1 |
|||
PRINT N, " " |
|||
LET I = I+1 |
|||
GOTO 10 |
|||
20 PRINT "" |
|||
PRINT "First 11 Woodall numbers:" |
|||
LET I = 1 |
|||
30 IF I = 12 THEN GOTO 40 |
|||
GOSUB 50 |
|||
LET N = (I*R) -1 |
|||
PRINT N, " " |
|||
LET I = I+1 |
|||
GOTO 30 |
|||
40 END |
|||
50 REM Exponent calculation |
|||
LET A = 2 |
|||
LET B = I |
|||
LET X = 1 |
|||
LET R = 2 |
|||
60 IF X >= B THEN RETURN |
|||
LET T = R |
|||
IF R < A THEN LET R = A*A |
|||
IF T < A THEN GOTO 70 |
|||
IF R >= A THEN LET R = R*A |
|||
70 LET X = X+1 |
|||
GOTO 60</syntaxhighlight> |
|||
{{out}} |
|||
<pre>First 11 Cullen numbers: |
|||
3 |
|||
9 |
|||
25 |
|||
65 |
|||
161 |
|||
385 |
|||
897 |
|||
2049 |
|||
4609 |
|||
10241 |
|||
22529 |
|||
First 11 Woodall numbers: |
|||
1 |
|||
7 |
|||
23 |
|||
63 |
|||
159 |
|||
383 |
|||
895 |
|||
2047 |
|||
4607 |
|||
10239 |
|||
⚫ | |||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
Line 332: | Line 397: | ||
END</syntaxhighlight> |
END</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
⚫ | |||
⚫ | |||
==={{header|XBasic}}=== |
==={{header|XBasic}}=== |