Скачиваний:
17
Добавлен:
01.05.2014
Размер:
850 б
Скачать
☆
program prost;
{ Џа®Ја ¬¬  ЈҐ­Ґа жЁЁ Їа®бвле зЁбҐ« ЇаЁ Ї®¬®йЁ  «Ј®аЁв¬  ќўЄ«Ё¤  }
const maxprime=1000;
type
  intarr=array[0..maxprime] of integer;
var
  primes: intarr;
  j,lastprime, curprime: integer;
  begin
   primes[0] := 2;
   primes[1] := 3;
   lastprime := 1;
   curprime  := 3;

   writeln('prime0 = ', primes[0]);
   writeln('prime1 = ',  primes[1]);
   while(curprime < MAXPRIME) do
      begin
       for j := 0 to lastprime do
          if((curprime mod primes[j]) = 0)
             then begin
                  curprime := curprime +2;
                  break;
                  end;
           if((j+1) <= lastprime) then continue;
           lastprime:= lastprime+1;
      writeln('prime ', lastprime,'=', curprime);
      primes[lastprime] := curprime;
      curprime := curprime +2;
      end
  end.
Соседние файлы в папке PROST