Selasa, 07 Agustus 2012

contoh program mencari bilangan prima di delphi

procedure TForm2.Button1Click(Sender: TObject);
var
  i, j, prima, jml: integer;
begin
  jml := StrToInt(Edit2.Text);
  ListBox1.Items.Clear;
  For i := StrToInt(Edit1.Text) to jml do
  Begin
    j := 0;
    For prima := 1 to i do
    Begin
      If i mod prima = 0 Then
        j := j + 1
    End;
    If j = 2 then
      ListBox1.Items.Add(IntToStr(i));
  End;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Edit1.Clear;
  Edit2.Clear;
end;

end.

illank bundrank

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 komentar:

Poskan Komentar