unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
m: TLabel;
n: TLabel;
Primzahlenzwillinge: TLabel;
Rechnen: TButton;
Ende: TButton;
procedure EndeClick(Sender: TObject);
procedure RechnenClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
m,n,x,i,h,u,zaehler,code:integer;
xstr,mstr:
string;
implementation
{$R *.DFM}
procedure TForm1.EndeClick(Sender: TObject);
begin
close
end;
procedure TForm1.RechnenClick(Sender: TObject);
begin
val(form1.edit1.text,m,code);
val(form1.edit2.text,n,code);
for i:=m
to n
do
//Primzahlentest
begin
zaehler:=0;
for h:=1
to m
do
if m
mod h=0
then zaehler:=zaehler+1;
end;
//Zwillingstest
begin
if zaehler=2
then x:=m+2;
zaehler:=0;
for u:=1
to x
do
if x
mod u=0
then zaehler:=zaehler+1;
if zaehler=2
then
begin
str(x,xstr);
str(m,mstr);
memo1.lines:=memo1.lines+mstr+'
,'+xstr+'
;';
end;
end;
end;
end.