The Sieve of Eratosthenes

Math 5370c - Fall 2008

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

PrimeQ[601]

Sieve[n_]:=Table[n k+l,{k,0,n-1},{l,1,n}]
n=601;
ES=Sieve[n];

k=1;While[Prime[k]≤n,ES=MapAll[(If[IntegerQ[#/Prime[k]]&&#/Prime[k]≥2,#/.#->0,#]&),ES];
Print[p[k]=ArrayPlot[Sign[ES],ImageSize->n, BaseStyle->{Black,Bold,{FontSize->16}},Epilog->Text[Prime[k],Scaled[{0.05,0.95}],Background->White]]];k++]
Clear[ES];

Prime[110]

Length[Table[p[k],{k,1,110}]]

p[10]

SetDirectory[NotebookDirectory[]]

Export["ani.flv",Table[p[k],{k,1,110}]]