unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function Silnia(n :Byte) :Int64;
var i :Byte;
begin
Result:=1;
for i:=1 to n do Result:=Result*i;
end;

function PodwojnaSilnia(n :Byte) :Int64;
var i :Byte;
begin
Result:=1;
for i:=1 to n do
  begin
  if Odd(i)<>Odd(n) then Continue;
  Result:=Result*i;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var n :Byte;
begin
try
  n:=StrToInt(Edit1.Text);
  ShowMessage(IntToStr(n)+'!='+IntToStr(Silnia(n)));
except
  on EConvertError do ShowMessage('Wpisz liczbę naturalną w polu edycyjnym');
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var n :Byte;
begin
try
  n:=StrToInt(Edit1.Text);
  ShowMessage(IntToStr(n)+'!!='+IntToStr(PodwojnaSilnia(n)));
except
  on EConvertError do ShowMessage('Wpisz liczbę naturalną w polu edycyjnym');
end;
end;

end.
