LF: Prime Number Generator


[Prev][Next][Index][Thread]

LF: Prime Number Generator



I am going to writing a prime number generator for 68k assembly.  I have
written a generator for BASIC, and I'm about to translate it into assembly.
 Does anyone have ANY ideas on how to make this program more efficient. 
(Just make some changes to the code, and send them back to me.)  One more
thing, this generator gets all the prime numbers from 3 and up.  It skips
the number 2 for the sake of speed...

CLS
OPEN "PRIME.DOC" FOR OUTPUT AS #1
Counter = 1
1 Counter = Counter + 2
Divider = 3
DO
 Divided = Counter / Divider
 IF FIX(Divided) - Divided = 0 THEN GOTO 1
 IF Divider >= SQR(Counter) THEN GOTO 2
 Divider = Divider + 2
LOOP
2 PRINT #1, Counter
SEEK (1), LOF(1) - 2
LOCATE 1, 1: PRINT Counter
GOTO 1

The only way to stop this program in BASIC is with the CTRL-BRK sequence.

When you send the code back to me (with changes you have made), send the
whole program.

Jonathan Oliver
daemon1@napanet.net


Follow-Ups: