用SQL 2005编程:求出1~999之间所有的同构数(一个数出现在其平方的右侧)。

如题所述

第1个回答  2012-03-26
declare @n int,@m int;
declare @t table(同构数 int)
set @n=0;
while(@n<999)
begin
set @n=@n+1;
select @m= case when @n<10 then 10 when @n<100 then 100 else 1000 end;
if (@n*@n-@n)%@m=0
insert into @t values (@n)
end
select * from @t结果:
同构数
1
5
6
25
76
376
675本回答被提问者采纳