Sieve of Eratosthenes

Discuss software for the Apple 1/replica 1

Sieve of Eratosthenes

Postby lorddoomicus » Jan Tue 20, 2009 11:57 pm

Here is my Woz BASIC Implementation of a prime number finder using the Sieve of Eratosthenes. You can crank up N a bit, but eventually you'll get MEM FULL ERR.

Code: Select all
100 PRINT "*** SIEVE OF ERATOSTHENES ***"
120 N=100
130 DIM S(N)
140 LET P=2
150 FOR I = 1 TO N
160 S(I) = I
170 NEXT I
180 PRINT P
190 FOR J = P TO N STEP P
200 LET S(J) = 0
210 NEXT J
220 LET P = P + 1
230 IF P = N THEN GOTO 500
240 IF S(P) <> 0 THEN GOTO 180
250 GOTO 220
500 END


Next up I'm working on a multiplication program that uses the Rhind papyrus method.

- Derrik
Derrik Walker v2.0, RHCE
http://www.doomd.net
lorddoomicus
 
Posts: 32
Joined: Sep Thu 07, 2006 10:30 pm
Location: Mentor Ohio

Return to Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron