如何求最小公倍数

来源:互联网 发布:控制学生上网软件 编辑:程序博客网 时间:2024/05/22 15:58

declare @t table (id int,value int)
insert @t select 1,5 union all select 2,6 union all select 3,15
declare @max int
select @max=max(value) from @t
declare @i int
select @i=1
while exists (select 1 from @t where @i*@max % value <> 0)
set @i = @i + 1
select @i*@max as 最小公倍数
/*
最小公倍数      
-----------
30
*/