–1.编程求1+2+3+…+100之和
declare @i int,@sum int
set @i=1
set @sum1=0
while @i<=100
begin
set @sum=@sum+@i1
set @i=@i+1
end
select’1+2+3+…+100和为’,@sum
–2.编程求1+3+5+…+99之和
declare @i int,@sum int
set @i=1
set @sum=0
while @i<=99
begin
set @sum=@sum+@i
set @i=@i+2
end
select’1+3+5+…+99和为’,@sum
–3.求2+4+6+…+100之和
declare @i int,@sum int
set @i=2
set @sum=0
while @i<=100
begin
set @sum=@sum+@i3
set @i=@i+2
end
select’2+4+6+…+100和为’,@sum
–4.编程求100以内所以被3整除的自然数之和
declare @i int,@sum in