Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.09 KB | None | 0 0
  1. unit Fermat;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Math, Vcl.StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Edit1: TEdit;
  13.     Edit2: TEdit;
  14.     ListBox1: TListBox;
  15.     Button2: TButton;
  16.     Label1: TLabel;
  17.     Label2: TLabel;
  18.     Label3: TLabel;
  19.     procedure Button1Click(Sender: TObject);
  20.     procedure Button2Click(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.   i, n: Integer;
  30.   r, a, b: Extended;
  31. implementation
  32.  
  33. {$R *.dfm}
  34.  
  35. procedure TForm1.Button1Click(Sender: TObject);
  36. begin
  37.   a := StrToFloat(Edit1.Text);
  38.   b := StrToFloat(Edit2.Text);
  39.   n := 0;
  40.   if a>b then ShowMessage('Zły przedział');
  41.   for i:= 1 to Trunc(b) do
  42.   begin
  43.     r := Power(2, Power(2, n)) + 1;
  44.     if (r>=a) and (r<=b) then ListBox1.Items.Add(FloatToStr(r));
  45.     Inc(n);
  46.   end;
  47. end;
  48.  
  49.  
  50. procedure TForm1.Button2Click(Sender: TObject);
  51. begin
  52. ListBox1.Items.Clear;
  53. end;
  54.  
  55. end.
Add Comment
Please, Sign In to add comment