sql求阶乘_PL / SQL程序查找数字的阶乘

PL/SQL阶乘程序
本文提供了一个PL/SQL程序,用于计算输入数字的阶乘。通过将数字与其以下的所有整数相乘,可以得到阶乘的结果。示例中演示了如何使用此程序计算10的阶乘。

sql求阶乘

Here you will get pl/sql program to find factorial of a number.

在这里,您将获得pl / sql程序来查找数字的阶乘。

We can calculate factorial of a number by multiplying it with all the numbers below it.

我们可以通过将数字乘以其下所有数字来计算阶乘。

For example factorial of 5 = 5 x 4 x 3 x 2 x 1 = 120.

例如5的阶乘= 5 x 4 x 3 x 2 x 1 = 120。

PL / SQL程序查找数字的阶乘 (PL/SQL Program to Find Factorial of a Number)

declare
	n number;
	fac number:=1;
	i number;
 
begin
	n:=&n;
 
	for i in 1..n
	loop
		fac:=fac*i;
	end loop;
 
	dbms_output.put_line('factorial='||fac);
end;
/

Output

输出量

Enter value for n: 10 old 7: n:=&n; new 7: n:=10; factorial=3628800

输入n的值:10 旧7:n:=&n; 新7:n:= 10; 阶乘= 3628800

翻译自: https://www.thecrazyprogrammer.com/2016/09/plsql-program-find-factorial-number.html

sql求阶乘

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值