oracle计算6的阶乘
oracle计算6的阶乘
更新时间:2019-07-08 14:30
最满意答案
select rownum rn, dbms_aw.eval_number(replace(wmsys.wm_concat(rownum)over(order by rownum), ',', '*')) serial_multi
2 from dual connect by rownum <=6;
可以参照 http://blog.itpub.net/12932950/viewspace-664600/
2018-11-19 回答
其他回答
create or replace procedure testtimes(int_num int, int_result out int) as
i int;
begin
int_result := 1;
for i in 2 .. int_num loop
int_result := i * int_result;
--dbms_output.put_line(int_result);
end loop;
end;
2018-11-19 回答
相关问答
#include long fac(unsigned n) { if (n == 0 || n == 1) { return 1; } else { return (n * fac(n - 1)); } } int main() { unsigned ui; printf("输入计算的 阶乘:"); scanf("%u", &ui); printf("%u的阶乘为:%u\n", ui, fac(ui)); return 0;
...
;汇编语言实现计算SUM=5! DATAS SEGMENT ;此处输入数据段代码 NUM DW 5 ;最高阶数 SUN DW 0 ;计算结果 DATAS ENDS STACKS SEGMENT ;此处输入堆栈段代码 STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX ;此处输入代码段代码 MOV CX,NUM MOV AX,1 ;被乘数 MOV SI,1 ;乘数 L1:
...
select rownum rn, dbms_aw.eval_number(replace(wmsys.wm_concat(rownum)over(order by rownum), ',', '*')) serial_multi 2 from dual connect by rownum <=6; 可以参照 http://blog.itpub.net/12932950/viewspace-664600/
在这里, a!! 被定义为(a!)! 。 123!!!!!! 绝对巨大 我想你需要比宇宙中更多的粒子,如果你要写下墨水。 因此,您无法直接比较数字。 我认为没有一个类可以做到这一点。 你可以做什么,就是考虑商123!!!!!! / 456!!! 123!!!!!! / 456!!! 。 许多倍数将是相似的,所以你可以取消它们。 注意尾随! 将取消。 这是因为x> y意味着x并暗示x! > y! 其中x和y是正整数。 最终你会达到一个点,你可以把它评估为小于或大于1,所以得到你的答案。 我可以告诉你
...
如果你不介意绝对精度,你可以使用双精度,它可以大到(大约) 1.8 * 10^308 。 如果关注精度,则应使用BigDecimal或BigInteger(factorial是一个整数函数,BigInteger在这种情况下可能比BigDecimal更有效)。 If you don't mind about absolute precision, you can use doubles, which can be as large as (approximately) 1.8 * 10^308. I
...
您可以在不评估单个因子的情况下解决此问题。 从计算上讲,您的公式简化为相当简单 1!/n! + 2!/n! + 3!/n! + ... + 1 除了第一个和最后一个术语之外,很多因素实际上都会取消,这将有助于最终结果的精确度,例如3! / n! 3! / n! 你只需要将1 / 4乘以1 / n 。 你不能做的是评估阶乘并除以它们。 如果15个十进制数字的精度是可接受的(看起来它来自你的问题),那么你可以用浮点来评估它,首先添加小项。 在开发算法时,您会注意到这些术语是相关的,但是在您冒着引入材料
...
在评论中,您最后说您不需要确切的结果。 只需使用浮点。 你需要处理的最大中间结果是59! ,约为1.3868e80 ; double类型足以保持该值。 写一个像这样的函数: double factorial(int n);
(我认为你知道如何实现它)并使用它。 如果您要进行大量这些计算,您可能希望通过将结果存储在数组中来缓存结果。 如果您定义一个数组,如: double fact[60];
那么你可以存储N!的值N! fact[N]代表N从0到59 - 你可以在计算59!所需的时间内填满整个数
...
MSB的答案有你的问题的要点:你的数组索引在几个地方超出界限。 在三个循环中, cifra - 1 == 0超出范围: do cifra=ncifras,1,-1
factor(1,cifra-1) = factor(1,cifra)/10 ! factor is (1:2, 1:ncifras)
factor(1,cifra) = mod(factor(1,cifra),10)
enddo
! :
! Same here:
do cifra=ncifras,1,-1
facto
...
我找到了答案,我们使用伽马函数来解决阶乘问题。 :(很抱歉打扰所有人!以下是详细信息: https ://groups.google.com/forum/#!msg / thethe-users / ytqep8AickA / cE7QeJZxXzUJ 所以这应该是: import theano
v = theano.tensor.scalar("variable")
factorial = theano.tensor.gamma(v)
# Calculate factorial of v ,
...
您需要在while循环开始时将factorial变量重置为1。 此外,您还需要检查每个输入的n是否为正,因为它目前仅针对第一个输入执行此操作。 You need to reset the factorial variable to 1 at the start of the while loop. Also, you'll want to check if n is positive for every input, as it currently only does so for the fir
...