使用T-SQL编程求S=1!+3!+5!+7!+...+N!,直到S大于10000时的N值和S值。

如题所述

declare @i int ,@sum int ,@j int,@K int select @i=1 select @sum=0 declare @tmpSum int select @k=0 while @sum<=10000 begin select @k=@k+1 select @i=@k*2-1 select @j=1 select @tmpSum=1 while @j<=@i begin select @tmpSum=@tmpSum*@j select @j=@j+1 end select @sum=@sum+@tmpSum end print(@sum) print(@i)
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答