The Sieve of Erastothenes

Math 5370c - Fall 2008

Helmut Knaust, Department of Mathematical Sciences, UTEP, El Paso TX 79968
hknaust@utep.edu
9/30/08

SetDirectory[NotebookDirectory[]]

Sieve[n_]:=Table[n k+l,{k,0,n-1},{l,1,n}]
n=150;
AP={};
ES=Sieve[n];
k=1;
While[Prime[k]≤n,ES=MapAll[(If[IntegerQ[#/Prime[k]]&&#/Prime[k]≥2,#/.#->0,#]&),ES];ES2=MapAll[Sign[#]&,ES];AP=Append[AP,ArrayPlot[ES2,ImageSize->450]];k++]
Length[AP]
Manipulate[AP[[i]],{i,1,Length[AP],1}]
Clear[ES,ES2];

Export["ani.swf",AP]

Export["ani.gif",AP]