Cod sursa(job #149879)

Utilizator netedu_andreiFII Andrei Netedu netedu_andrei Data 6 martie 2008 10:47:58
Problema Ciurul lui Eratosthenes Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.39 kb
program ciur;
var f,g:text;
    i,j,n,k:longint;
    a:array[1..63000]of byte;
begin
assign(f,'ciur.in');reset(f);
assign(g,'ciur.out');rewrite(g);
readln(f,n);
for i:=2 to n do
    if a[i]=0 then begin
                   k:=i;
                   for j:=2 to n div k do a[j*k]:=1;

                   end;
for i:=2 to n do
    if a[i]=0 then write(g,i,' ');
close(f);
close(g);
end.