相关疑难解决方法(0)

计算任意大数的阶乘,显示所有数字

最近我在一次采访中被要求描述一种计算任意大数的阶乘的方法; 一种方法,我们获得答案的所有数字.

我搜索了不同的地方,并在几个论坛上询问.但我想知道是否有任何方法可以在不使用像GMP这样的库的情况下实现这一目标.

谢谢.

c++ factorial

22
推荐指数
3
解决办法
2万
查看次数

如何处理任意大整数

我正在编写一种编程语言,今天我得到了可以编译阶乘函数(递归)的点,但是由于整数的最大值,我能得到的最大值是阶乘(12).什么是处理任意最大大小的整数的技术.该语言目前通过将代码转换为C++来工作.

c++ integer overflow integer-overflow long-integer

13
推荐指数
2
解决办法
2万
查看次数

无法计算大于20的阶乘!!怎么办?

我使用无符号长整数格式来计算大因子.但是我的代码在某些时候失败了你能看一下吗?实际上它是指数函数的泰勒展开的更大代码的一部分,但是这一部分在这一点上是无关紧要的.我将不胜感激任何建议.

谢谢

#include <stdio.h>
#include <math.h>
//We need to write a factorial function beforehand, since we
//have factorial in the denominators.
//Remembering that factorials are defined for integers; it is
//possible to define factorials of non-integer numbers using
//Gamma Function but we will omit that.
//We first declare the factorial function as follows:
unsigned long long factorial (int);
//Long long integer format only allows numbers in the order of 10^18 so 
//we shall use the sign bit in order to …
Run Code Online (Sandbox Code Playgroud)

c gcc factorial

13
推荐指数
3
解决办法
1万
查看次数

用于计算大因子的商的C++程序

如何编写c ++程序来计算大因子.

例如,如果我想计算(100!)/(99!),我们知道答案是100,但如果我分别计算分子和分母的阶乘,那么这两个数字都是巨大的.

c++

9
推荐指数
3
解决办法
7257
查看次数

标签 统计

c++ ×3

factorial ×2

c ×1

gcc ×1

integer ×1

integer-overflow ×1

long-integer ×1

overflow ×1