C 练习实例25 之mysql实现

题目:求1+2!+3!+...+20!的和。

 

drop PROCEDURE if exists test;
 
create PROCEDURE test (     )  
 begin 
		 
    declare i int;
    declare sum,mix long;
    
		set sum=0,mix=1,i=1;
		while i<=20 do 
			set	mix=mix*i;
      set sum=sum+mix;
			set i=i+1;
		end while;
     
   
		select sum;
end;  

 

你可能感兴趣的:(mysql)