unit uSum;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    PotenzEin: TEdit;
    Label1: TLabel;
    ErgebnisAus: TEdit;
    Label2: TLabel;
    Rechne: TButton;
    Ende: TButton;
    procedure RechneClick(Sender: TObject);
    procedure EndeClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.RechneClick(Sender: TObject);
var k, n, pot, sum :integer;
begin
   n := strtoint(PotenzEin.text);
   pot := 1;
   sum := 1;
   k := 0;
   while k < n do
   begin
       k := k+1;
       pot := 2*pot;
       sum := sum + pot;
   end;
   ErgebnisAus.Text := inttostr(sum);
end;

procedure TForm1.EndeClick(Sender: TObject);
begin
  close;
end;

end.
