procedure TForm18.Button1Click(Sender: TObject);
var n,i,m,s :integer;
p:boolean;
begin
m:= strtoint(edit1.Text);
for n:= 2 to 1000 do
begin
i:=2;
p:=true;
while (i< n-1) and p do
begin
s:= n mod i;
if s = 0
then p := false;
i:= i+1;
end;
if listbox1.count < m
then if p = true
then listbox1.Items.Add('Bilangan Prima ke ' + inttostr(listbox1.Items.count+1) + ' adalah ' + inttostr(n));
end;
end;
CONVERSATION
Subscribe to:
Post Comments
(
Atom
)
0 komentar:
Post a Comment