procedure TForm1.Button1Click(Sender: TObject);
var s1,s2,s3,s4 :String;
var i,lengt,len,flag:integer;
var sum:real48;
var t0,t1,t2:extended;
begin
s1 := Edit1.Text;
flag := 1;
s2 := s1;
s3 := s2;
lengt := Length( s2 );
sum := 0;
len := lengt;
for i:=1 to len do
sum:=sum + integer(s2[i]);
t2 := sum;
t0 := (ln(sum/1294.39894) + sqrt( 0.296439*sum ))*t2;
t1 := sin(lengt);
sum := cos( t0
+ cos(lengt * sum) * t1 );
Str(sum:23,s2 );
//s2 := ' 7.91792776828515E-0001';
//Edit1.Text := s2;
//sum := 0;
len := length( s2 );
for i:=len downto 1 do
begin
if i = 18 then
s4:=s4+char(integer(s2[ i - 10 ]) + i + $2a)
else if i = 17 then
s4:=s4+char(integer(s2[ i ]) + $30 )
else if i = 16 then
s4:=s4+char(integer(s2[ i ]) + i + $1a )
else if i = 15 then
s4:=s4+char(integer(s2[ i ]) +i*i - $ac )
else if i = 14 then
s4 := s4 + char(integer(s2[ i ]) +i + $1e )
else if i = 13 then
s4 := s4 + char(integer(s2[ i ]) + i div i + $2e )
else if i = 12 then
s4 := s4 + char(integer(s2[ i ]) +i - $21 )
else if i = 2 then
s4 := char(integer(s2[ i ])+ i * i + 6) + s4
else if i = 10 then
s4 := s4 + char(integer(s2[ 3 ]) - ( 2 * i - 7 ) );
end;
if integer(s2[6]) + $16 <> integer(s3[6]) then flag:=0;
if integer(s2[7])*2 - 9 <> integer(s3[9]) then flag:=0;
len := length(s4 );
for i:=1 to len do
lengt := lengt + integer( s4[i] );
if (integer(s2[4])*9 + (len + 1 )*2 + integer(s2[5])*4 = lengt )
and (flag = 1) then
begin
Edit1.Text := s4;
end
else
begin
Edit1.Text := 'Wrong!';
end;
// Edit1.Text := s2;
end;