**Centralia Junior High School**

Centralia, Illinois

Math and Computers

(All rights reserved. Do not reproduce without permission.)

# Prime Sieve in Action created with LOGO

Using pcLogo for Windows, Harvard Associates, Inc.

Click Here
to view Logo Procedures for MSW Logo.

## The Logo procecures listed here create these results with action color and sound to illustrate a prime sieve.

TO PRIMES

FS CS HT PU

SETPC 12 SETFONT "TIMES 16 1

SETXY [-85 220] PD TT [PRIME SIEVE]

SETPC 1 SETFONT "COURIER 12 1

PRNTARRAY 2

SIEVE 2 2

SIEVE 3 3

SIEVE 5 5

SIEVE 7 7

SIEVE 11 11

SIEVE 13 13

WAITKEY CS SS

END

TO PRNTARRAY :N

IF :N 200 [STOP]

PU SETXY CALCPOS :N PD

TT :N

PRNTARRAY :N + 1

END

TO SIEVE :N :I

IF :I * :N 200 [STOP]

SETPC 12

PU SETXY CALCPOS :I * :N

PD TT :N * :I TONE :N * 80 4

SETPC 7 TT :N * :I

SIEVE :N :I + 1

END

TO CALCPOS :N

MAKE "X (4 * REMAINDER (:N - 1) 10)

IF :N <10 [MAKE "X :X + 1]>

IF :N <100 [MAKE "X :X + 1]>

MAKE "Y (INT (:N - 1) / 10)

OP LIST 10 * :X - 220 180 - 20 * :Y

END

TO WAITKEY

IF KEY? [STOP]

WAITKEY

END

### Type PRIMES in the listener window after defining the procedures in the editor window.

[ Return to Main Logo Page ]
[ Return to CJHS Page ]