#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Sieve of Eratosthenes using LC3

Member Posts: 1
Hi can someone please guide me how to do this problem. I just started this course but I am sooo confused....

The LC-3 Implementation
=======================================================================

- THE ARRAY

You will be using the FILL command to allocate 3001 words of memory
with which you will be storing the list of prime numbers:

PRIMES .BLKW 3001

You MUST ensure that your list of primes is labeled using PRIMES.
Also, you may be wondering why '3001' and not '3000'. Remember, to
determine the actual size needed for a 0-based array you need 'end -
start + 1' spaces, so this comes out to '3000 - 0 + 1', or '3001'.

- THE STEPS

The first step of your algorithm is, of course, to iterate over this
memory setting all of the 'array' indexes to their respective values
as described above.

Then, you simply proceed with the algorithm above. Once you are
finished determining all of the prime numbers between 2 and 3000,

You may be wondering how you can check if your algorithm is correct.
Well, the reason you are storing the actual value of the index rather
than a simple '1' or '0' (for 'prime' or 'not prime' respectively) is
so you can rapidly look through the memory and determine if the
numbers you found to be prime are indeed prime.

- GOTCHAS

When doing this, we recommend you make printouts and label what each
register is doing in each part of the program. You will find
yourself using registers to do three entirely different things with
registers:

- An index, such as a counter.
- A pointer, or a memory address.
- A plain number read from memory.

Restrictions
=======================================================================

1 - Your program must finish before 1,000,000 instructions are
executed. If your program executes more than this, then it will

As long as you follow the algorithm above, you do not have to

2 - You must start your array of primes by labelling it PRIMES in

3 - You must store the elements of the array in the format we specify.
Be sure to double-check that the beginning of PRIMES corresponds
to the number 0.

• Member Posts: 2,444
"The first step of your algorithm is, of course, to iterate over this
memory setting all of the 'array' indexes to their respective values
as described above."