Sieve for Atari 520STfm

Anything you want to discuss about your vintage computer, or accessories for it, from general usage to advanced modding.

Sieve for Atari 520STfm

Postby Trygve » Tue Oct 04, 2005 8:10 pm

Managed to get hold of MetaComCo Basic, the revised edition for this machine, so decided to tackle the problem on this machine...

This is the code for an 8bit( up to 255) challenge...

Code: Select all

100 DIM A%(255)
110 K% = 1
120 WHILE K% < 128
130 FOR N% = K%+1 TO 255
140 IF A%(N%) > 0 GOTO 160
150 IF N% = (N%\K%)*K% THEN A%(N%) = 1
160 NEXT N%
170 FOR N% = k%+1 to 255: IF A%(N%) = 1 THEN GOTO 177
172 K% = N%: N% = 255
175 NEXT N%
180 WEND
190 FOR N% = 1 to 255: IF A%(N%) = 0 THEN PRINT N%: NEXT N%
200 END


This snippet takes about 13 seconds to run. I haven't included any code to preserve the result after ending, not only because the table is still accessible afterwards, but also because the IDE which the Basic interpreter is built into has an output window wchich the numbers can be found in.

As this simple task took 13 seconds, and I can't seem to be able to create a table big enough to deal with the 16bit challenge, and what seems to be a lack of MODULO or REMAINDER functions, it's also not that easy to use a smaller table and let different bits in each sell stand in for different numbers.

Someone PLEASE TELL ME that it's possible to speed this up significantly!
User avatar
Trygve
Über Geek
 
Posts: 108
Joined: Sun Jun 19, 2005 9:49 pm
Location: Norway

Return to General computer talks

Who is online

Users browsing this forum: No registered users and 1 guest

cron