很简单嘛!
function IsPrime (N: LongInt): Boolean;
var
Test: LongInt;
begin
IsPrime := True;
for Test := 2 to N - 1do
begin
if (N mod Test) = 0 then
begin
IsPrime := False;
break;
{jump out of the for loop}
end;
end;
end;
你再从100-10000做一个循环:
procedure TForm1.Button1Click(Sender: TObject);
var
i,n:Integer;
begin
n:=0;
for i := 100 to 10000do
begin
if IsPrime(i) then
n:=n+1;
end;
ShowMessage(IntToStr);
end;
答案:1204个