unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    z_bin_do_dec: TMemo;
    scita_1_10_nasobkov_cisla: TMemo;
    z_dec_do_bin_citaj_zdola_hore: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure z_bin_do_decChange(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form1: TForm1;
  cislo: integer;
  zvysok: integer;
  i: integer;

  cislo_2: integer;
  zvisok: integer;
  bin_nasobok: integer;
  cifra: integer;
  cislo_visledne: integer;

  cislo_3: integer;
  p: integer;
  sucet: integer;
  nasobky: integer;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
   cislo := StrToInt(Edit1.text);
   repeat
    begin
      zvysok := cislo mod 2;
      cislo:= cislo div 2;
      z_dec_do_bin_citaj_zdola_hore.lines.append(inttostr(zvysok));
     end;

   until  cislo=0;


end;

procedure TForm1.Button2Click(Sender: TObject);
begin
     zvisok :=0;
     bin_nasobok :=1;
     cislo_visledne :=0;
     cifra :=0;

  cislo_2 := strtoint(Edit3.text);
  z_bin_do_dec.lines.append(inttostr(cislo_2)+' cislo_2');
  repeat
    begin
       zvisok := cislo_2 mod 10;
       cislo_2 := cislo_2 div 10 ;
       bin_nasobok := bin_nasobok*2;
       cifra := zvisok*bin_nasobok;
                if bin_nasobok=1 then
                   begin
                    bin_nasobok := bin_nasobok+1;
                   end;
       cislo_visledne := cislo_visledne + cifra;
    end;
   until cislo_2=0;
   cislo_visledne := cislo_visledne div 2;

   z_bin_do_dec.lines.append(inttostr(cislo_visledne)+' visledok');

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  cislo_3 := StrToInt(Edit4.text);
  sucet:= 0;
  nasobky :=0;
  p := 0;
  for i:= 1 to 10 do
  begin
     p := p + 1;
     nasobky := cislo_3*p;
     scita_1_10_nasobkov_cisla.lines.append(inttostr(nasobky));
     sucet := sucet + nasobky;
  end;
  scita_1_10_nasobkov_cisla.lines.append(inttostr(sucet));
end;

procedure TForm1.z_bin_do_decChange(Sender: TObject);
begin

end;

end.

