Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Fermat;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Math, Vcl.StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Edit1: TEdit;
- Edit2: TEdit;
- ListBox1: TListBox;
- Button2: TButton;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- i, n: Integer;
- r, a, b: Extended;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- a := StrToFloat(Edit1.Text);
- b := StrToFloat(Edit2.Text);
- n := 0;
- if a>b then ShowMessage('Zły przedział');
- for i:= 1 to Trunc(b) do
- begin
- r := Power(2, Power(2, n)) + 1;
- if (r>=a) and (r<=b) then ListBox1.Items.Add(FloatToStr(r));
- Inc(n);
- end;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- ListBox1.Items.Clear;
- end;
- end.
Add Comment
Please, Sign In to add comment