unit main;

interface

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

type
  TForm1 = class(TForm)
    PrimeList: TListBox;
    Min: TEdit;
    Max: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Primes: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
 Low, High, Count, Count2: Integer;
begin
 { Czycimy list }
 PrimeList.Items.Clear;
 { Okrelamy zakres na podstawie wprowadzonych wartoci }
 Low := StrToInt(Min.Text);
 High := StrToInt(Max.Text);

 { Dla kadej wartoci z zakresu - ptla }
 for Count := Low to High do
 begin
  Count2 := 2;

  { sprawdzamy, czy licznik jest dzielnikiem liczby Count }
  while (Count2 < Count) and not(Count mod Count2 = 0) do
    inc(Count2);

  { dodajemy liczbe pierwsz do listy }
  if (Count = Count2) then
    PrimeList.Items.Add(IntToStr(Count));

 end; { for }
end; { proc }

end. { program }