plsql计算s=1!+2!+...+10!。
时间: 2023-11-27 15:03:55 浏览: 100
以下是PL/SQL计算S=1!+2!+...+10!的代码:
```sql
DECLARE
S INT := 0;
J INT;
BEGIN
FOR L IN 1..10 LOOP
J := 1;
FOR I IN 1 .. L LOOP
J := J * I;
END LOOP;
S := S + J;
END LOOP;
DBMS_OUTPUT.PUT_LINE(S);
END;
```
输出结果为:4037913
相关问题
PLSQL Developer 12 (64 bit)计算s=1!+2!+...+10!
以下是PLSQL Developer 12 (64 bit)计算s=1!+2!+...+10!的代码:
```sql
DECLARE
s NUMBER := 0;
factorial NUMBER := 1;
BEGIN
FOR i IN 1..10 LOOP
factorial := factorial * i;
s := s + factorial;
END LOOP;
DBMS_OUTPUT.PUT_LINE('s = ' || s);
END;
```
运行结果为:
```
s = 4037913
```
PLSQL Developer 12 (64 bit)计算s=1!+2!+...+10!。
以下是PLSQL Developer 12 (64 bit)计算s=1!+2!+...+10!的代码:
```sql
DECLARE
s NUMBER := 0;
fact NUMBER := 1;
BEGIN
FOR i IN 1..10 LOOP
fact := fact * i;
s := s + fact;
END LOOP;
DBMS_OUTPUT.PUT_LINE('s = ' || s);
END;
```
运行结果为:
```
s = 4037913
```
阅读全文