O'Halloran numbers: Difference between revisions
Content added Content deleted
(Added Easylang) |
(Added Chipmunk Basic, True BASIC and QBasic) |
||
Line 149: | Line 149: | ||
<pre>All known O'Halloran numbers: |
<pre>All known O'Halloran numbers: |
||
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924 </pre> |
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924 </pre> |
||
==={{header|Chipmunk Basic}}=== |
|||
{{trans|BASIC256}} |
|||
{{works with|Chipmunk Basic|3.6.4}} |
|||
{{works with|QBasic}} |
|||
<syntaxhighlight lang="vbnet">100 cls |
|||
110 maxarea = 1000 |
|||
120 halfmaxarea = maxarea/2 |
|||
130 dim t(halfmaxarea)'table of half areas |
|||
140 for i = 0 to halfmaxarea-1 |
|||
150 t(i) = 1 'assume all are O'kalloran numbers |
|||
160 next i |
|||
170 for l = 1 to maxarea |
|||
180 for w = 1 to halfmaxarea |
|||
190 for h = 1 to halfmaxarea |
|||
200 suma = l*w+l*h+w*h |
|||
210 if suma < halfmaxarea then t(suma) = 0 'not an O'kalloran number |
|||
220 next h |
|||
230 next w |
|||
240 next l |
|||
250 print "All known O'Halloran numbers:" |
|||
260 print "[ "; |
|||
270 for l = 6/2 to halfmaxarea-1 |
|||
280 if t(l) then print int(l*2);" "; |
|||
290 next l |
|||
300 print chr$(8);"]" |
|||
310 end</syntaxhighlight> |
|||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |
||
Line 176: | Line 203: | ||
<pre>All known O'Halloran numbers: |
<pre>All known O'Halloran numbers: |
||
[ 8, 12, 20, 36, 44, 60, 84, 116, 140, 156, 204, 260, 380, 420, 660, 924 ]</pre> |
[ 8, 12, 20, 36, 44, 60, 84, 116, 140, 156, 204, 260, 380, 420, 660, 924 ]</pre> |
||
==={{header|QBasic}}=== |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBasic|4.5}} |
|||
The [[#Chipmunk Basic|Chipmunk Basic]] solution works without any changes. |
|||
==={{header|True BASIC}}=== |
|||
{{trans|BASIC256}} |
|||
<syntaxhighlight lang="qbasic">LET maxarea = 1000 |
|||
LET halfmaxarea = maxarea/2 |
|||
DIM t(1) |
|||
MAT REDIM t(0 TO halfmaxarea) !Table of half areas |
|||
FOR i = 0 TO halfmaxarea-1 |
|||
LET t(i) = 1 !assume all are O'kalloran numbers |
|||
NEXT i |
|||
FOR l = 1 TO maxarea |
|||
FOR w = 1 TO halfmaxarea |
|||
FOR h = 1 TO halfmaxarea |
|||
LET suma = l*w+l*h+w*h |
|||
IF suma < halfmaxarea THEN LET t(suma) = 0 !not an O'kalloran number |
|||
NEXT h |
|||
NEXT w |
|||
NEXT l |
|||
PRINT "All known O'Halloran numbers:" |
|||
FOR l = 6/2 TO halfmaxarea-1 |
|||
IF t(l) = 1 THEN PRINT INT(l*2);" "; |
|||
NEXT l |
|||
END</syntaxhighlight> |
|||
==={{header|Yabasic}}=== |
==={{header|Yabasic}}=== |