Minggu, 30 Oktober 2016

Program Delphi Untuk Mencari FPB dan KPK

procedure TFPBdanKPK.Button1Click(Sender: TObject);

Var
  a,b,d,c,e,p,n,jml:integer;
begin
  a:=strtoint(edit1.Text);
  b:=strtoint(edit2.text);
  jml:=1;
  n:=a+b;
  for d:= 1 to n do
  begin
  c:=a mod d;
  e:=b mod d;
  if (c=0) and (e=0) then
  begin
  p:=d;
  edit3.Text:=inttostr(p);
  end;
  end;
  end;



procedure TFPBdanKPK.Button2Click(Sender: TObject);

var
a,b,d,c,e,p,n,jml,k:integer;
begin
  a:=strtoint(edit1.Text);
  b:=strtoint(edit2.text);
  jml:=1;
  n:=a+b;
  for d:= 1 to n do
  begin
  c:=a mod d;
  e:=b mod d;
  if (c=0) and (e=0) then
  begin
  p:=d;
  k:=(a*b) div (p);
  edit3.Text:=inttostr(k);
  end;
  end;
  end;



procedure TFPBdanKPK.Button3Click(Sender: TObject);
begin
edit1.Text:=' ';
edit2.Text:=' ';
edit3.Text:=' ';

end;

procedure TFPBdanKPK.Button4Click(Sender: TObject);
begin
AplikasiBilanganBulat.Show;
FPBdanKPK.Hide;
end;

0 komentar:

Posting Komentar