编写一程序块计算:1!+2!+3!+4!+…………+n!(用sql编写)

2024-12-03 02:47:09
推荐回答(3个)
回答1:

declare i,k,temp,sum int
set i=1,k=1,sum=0
while i<=n begin
temp=1
while k<=i begin
temp=temp*k
end
sum=sum+temp
end
sum即为值

回答2:

declare
n number := 4;--你的n
v_n number := 1;
v_sum number := 0;
begin
v_n := 1;
for r2 in 1 .. n loop
v_n := v_n * r2;
v_sum := v_sum + v_n;
end loop;
end;

回答3:

SQL> CREATE OR REPLACE FUNCTION F_SUM_MULTI(P_IN IN NUMBER) RETURN NUMBER AS
2 V_RESULT_MULTI NUMBER DEFAULT 1;
最多只能100字
了解更多,
http://blog.csdn.net/wan_sun/archive/2009/10/30/4746675.aspx