Cullen and Woodall numbers: Difference between revisions
Content added Content deleted
mNo edit summary |
(Cullen and Woodall numbers in various dialects BASIC (Gambas, Run BASIC and XBasic)) |
||
Line 175: | Line 175: | ||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
==={{header|BASIC256}}=== |
==={{header|BASIC256}}=== |
||
{{works with|Run BASIC}} |
|||
{{works with|Just BASIC}} |
|||
{{works with|Liberty BASIC}} |
|||
{{trans|FreeBASIC}} |
{{trans|FreeBASIC}} |
||
<syntaxhighlight lang="basic256">print "First 20 Cullen numbers:" |
<syntaxhighlight lang="basic256">print "First 20 Cullen numbers:" |
||
Line 195: | Line 195: | ||
end</syntaxhighlight> |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
⚫ | |||
</pre> |
|||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="vb">Dim As Uinteger n, num |
||
Print "First 20 Cullen numbers:" |
Print "First 20 Cullen numbers:" |
||
Line 221: | Line 219: | ||
First 20 Woodall numbers: |
First 20 Woodall numbers: |
||
1 7 23 63 159 383 895 2047 4607 10239 22527 49151 106495 229375 491519 1048575 2228223 4718591 9961471 20971519</pre> |
1 7 23 63 159 383 895 2047 4607 10239 22527 49151 106495 229375 491519 1048575 2228223 4718591 9961471 20971519</pre> |
||
==={{header|Gambas}}=== |
|||
<syntaxhighlight lang="vbnet">Public Sub Main() |
|||
Dim n, num As Integer |
|||
Print "First 20 Cullen numbers:" |
|||
For n = 1 To 20 |
|||
num = n * (2 ^ n) + 1 |
|||
Print num; " "; |
|||
Next |
|||
Print "\n\nFirst 20 Woodall numbers:" |
|||
For n = 1 To 20 |
|||
num = n * (2 ^ n) - 1 |
|||
Print num; " "; |
|||
Next |
|||
End </syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
==={{header|PureBasic}}=== |
==={{header|PureBasic}}=== |
||
Line 241: | Line 262: | ||
CloseConsole()</syntaxhighlight> |
CloseConsole()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
⚫ | |||
</pre> |
|||
==={{header|QBasic}}=== |
==={{header|QBasic}}=== |
||
Line 268: | Line 287: | ||
END</syntaxhighlight> |
END</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
⚫ | |||
==={{header|Run BASIC}}=== |
|||
</pre> |
|||
{{works with|BASIC256}} |
|||
{{works with|Just BASIC}} |
|||
{{works with|Liberty BASIC}} |
|||
<syntaxhighlight lang="vb">print "First 20 Cullen numbers:" |
|||
for n = 1 to 20 |
|||
num = n * (2^n)+1 |
|||
print int(num); " "; |
|||
next |
|||
print : print |
|||
print "First 20 Woodall numbers:" |
|||
for n = 1 to 20 |
|||
num = n * (2^n)-1 |
|||
print int(num); " "; |
|||
next n |
|||
end</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
Line 296: | Line 335: | ||
Igual que la entrada de FreeBASIC. |
Igual que la entrada de FreeBASIC. |
||
</pre> |
</pre> |
||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
<syntaxhighlight lang="qbasic">PROGRAM "progname" |
|||
VERSION "0.0000" |
|||
IMPORT "xma" |
|||
DECLARE FUNCTION Entry () |
|||
FUNCTION Entry () |
|||
PRINT "First 20 Cullen numbers:" |
|||
FOR n = 1 TO 20 |
|||
num! = n * POWER (2, n) + 1 |
|||
PRINT num!; |
|||
NEXT n |
|||
PRINT |
|||
PRINT |
|||
PRINT "First 20 Woodall numbers:" |
|||
FOR n = 1 TO 20 |
|||
num! = n * POWER (2, n) - 1 |
|||
PRINT num!; |
|||
NEXT n |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
==={{header|Yabasic}}=== |
==={{header|Yabasic}}=== |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="basic">print "First 20 Cullen numbers:" |
||
for n = 1 to 20 |
for n = 1 to 20 |
||
Line 314: | Line 383: | ||
end</syntaxhighlight> |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
⚫ | |||
</pre> |
|||