Da kommst du ja auf den letzten Pfiff
Zitat:
function prim(zahl:integer):boolean;
var i:integer;
begin
result:=true;
for i:=2 to round(sqrt(zahl)) do
if zahl mod i=0 then
result:=false;
end;
procedure tform1.button1click(sender: tobject);
var i:integer;
begin
listbox1.clear;
for i:=2 to strtoint(edit1.text) do
if prim(i)=true then
listbox1.items.add(inttostr(i));
form1.caption:=inttostr(listbox1.items.count);
end;
end.
|
Gib Bescheid, wenn du was nicht verstehst. Wir hatten das selber mal im Unterricht behandelt.