Cod sursa(job #642009)

Utilizator andrei_toaderToader Andrei Sorin andrei_toader Data 30 noiembrie 2011 12:59:06
Problema Ciurul lui Eratosthenes Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.94 kb
program info;
var f,g:text;
   v:array[1..100000000] of byte;
   n,i,aux:integer;
begin
assign (f,'ciur.in'); reset (f);
assign (g,'ciur.out'); rewrite (g);
  read (f,n);
  for i:=2 to 7 do
    begin
     if i=2 then
      begin
       aux:=i;
       while aux<=n do
         begin
          aux:=aux+i;
          v[aux]:=1;
         end;
      end;
     if i=3 then
      begin
       aux:=i;
       while aux<=n do
         begin
          aux:=aux+i;
          v[aux]:=1;
         end;
      end;
     if i=5 then
      begin
        aux:=i;
        while aux<=n do
          begin
           aux:=aux+i;
           v[aux]:=1;
          end;
       end;
      if i=7 then
        begin
         aux:=i;
          while aux<=n do
          begin
           aux:=aux+i;
           v[aux]:=1;
          end;
      end;
    end;
  for i:=2 to n do
  if v[i]=0 then
    write (g,i,' ');
close (f);
close (g);
end.