unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
Button2: TButton;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button2Click(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a: real;
n,x: int64;
b: array [1 .. 99999999] OF real;
c: boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Text = '') OR (Edit1.Text = '0') OR (Edit2.Text = '') then messagedlg('You must enter a number from 1',mtWarning,mbOKCancel,1)
else
begin
c:= false;
n:=strtoint(Edit2.Text);
x:=strtoint(Edit1.Text);
Memo1.Text:=#0;
while n < x do
begin
n:=n+1;
a:=n-1;
while a > 0 do
begin
if a <> 1 then
begin
if a <> n then
begin
b[n] := n/a;
if b[n] = round(b[n]) then
c:= true;
end;
end;
a:=a-1;
end;
if c = false then Memo1.Text:=Memo1.Text + ' ' + inttostr(n);
c:= false;
end;
end;
ActiveControl := Button2;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Memo1.Text:=#0;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then Button1.Click
else
begin
if (Key > '9') OR (Key < '0') AND (Key <> #8) then
begin
Key := #0;
MessageDlg('You may only use numbers.',mtWarning,mbOKCancel,1)
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Text := #0;
Edit1.Text := '0';
Edit2.Text := '0';
ActiveControl := Edit2;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then ActiveControl := Edit1
else
begin
if ((Key > '9') OR (Key < '0')) AND (Key <> #8) then
begin
Key := #0;
MessageDlg('You can only use numbers',mtWarning,mbOKCancel,1)
end;
end;
end;
end.