image1 image2

BUBURBULATです |WELCOME TO MY PERSONAL BLOG|数学と芸術が大好き

N bilangan prima pertama

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;

Share this:

CONVERSATION

0 komentar:

Post a Comment