Pagini recente » Cod sursa (job #596390) | Cod sursa (job #1077478) | Cod sursa (job #770880) | Borderou de evaluare (job #1520363) | Cod sursa (job #1102170)
Program A1;
uses crt;
var n:longint;
function ciur(var n:longint):longint;
var a:array[2..500] of boolean;
i,k,prim:longint;
begin
prim:=0;
for i:= 2 to n do
a[i]:=false;
for i:=2 to n do
begin
if not(a[i]) then
begin
inc(prim);
k:=2*i;
while k<=n do
begin
a[k]:=true;
k:=k+i;
end;
end;
end;
ciur:=prim;
end;
begin
clrscr;
write('n=');readln(n);
writeln('Numarul de numere prime:',ciur(n));
readln;
end.