Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы по МПО / МПО / Lab2 / Part1_Prosto / PAS Version / PROST0_P
.PAS 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.
{ Џа®Ја ¬¬ ЈҐҐа жЁЁ Їа®бвле зЁбҐ« ЇаЁ Ї®¬®йЁ «Ј®аЁв¬ ќўЄ«Ё¤ }
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.