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 MSW Logo, Softronics, Inc.

Click Here to view Logo Procedures for pcLogo.

 

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

TO primes
cs ht pu
setpc 4
setxy -85 220 PD label [Prime Sieve]
setpc 1
prntarray 2
sieve 2 2
sieve 3 3
sieve 5 5
sieve 7 7
sieve 11 11
sieve 13 13
END

TO prntarray :n
if :n > 200 [stop]
pu setxy calcx :n calcy :n pd
label :n
prntarray :n + 1
END

TO sieve :n :i
if :i * :n > 200 [stop]
setpc 4
pu setxy calcx :i * :n calcy :i * :n
pd label :n * :i sound list :n * 80 80
setpc 15 label :n * :i
sieve :n :i + 1
END

TO calcx :n
make "x (4 * remainder (:n - 1) 10)
if :n < 10 [make "x :x + 1]
if :n < 100 [make "x :x + 1]
op 10 * :x - 220
END

TO calcy :n
make "y (int (:n - 1) / 10)
op 180 - 20 * :y
END

Type PRIMES in the command window after defining the procedures in the editor window.


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