下面的方法需要三、四分钟,而且不知道答案是否正确:
function cacl(a: integer): integer; //求六次方的函数
var
b:integer;
begin
b:=0;
asm
xor eax,eax
xor esi,esi
mov eax,a
mov ecx,eax
mov esi,$6
@:
imul eax,ecx
dec esi
jne @
mov b,eax
end;
Result := b;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s,i:integer;
c:string;
d:string;
begin
repeat
i := 1000000 + Random(9999999);
d:=inttostr(i);
s:=cacl(strtoint(midstr(d,1,1)))+
cacl(strtoint(midstr(d,2,1)))+
cacl(strtoint(midstr(d,3,1)))+
cacl(strtoint(midstr(d,4,1)))+
cacl(strtoint(midstr(d,5,1)))+
cacl(strtoint(midstr(d,6,1)))+
cacl(strtoint(midstr(d,7,1)));
begin
for i := 1000000 to 9999999 do
begin
d:=inttostr(i);
s1:=cacl(strtoint(midstr(d,1,1)));
s2:=cacl(strtoint(midstr(d,2,1)));
s3:=cacl(strtoint(midstr(d,3,1)));
s4:=cacl(strtoint(midstr(d,4,1)));
s5:=cacl(strtoint(midstr(d,5,1)));
s6:=cacl(strtoint(midstr(d,6,1)));
s7:=cacl(strtoint(midstr(d,7,1)));
s:=s1+s2+s3+s4+s5+s6+s7;
if inttostr(s)=d then
ListBox1.Items.Add(inttostr(s));
end;
end;