有什么办法可以得到欧拉数和整数的乘积之和,其中整数的范围可达 10^6000?

is there any way to get the sum of the product of euler's number and an integer, where the integer can range upto 10^6000?

所以我尝试使用 BigDecimal,它给我欧拉数的值最多 50 个小数点。但是由于约束值这么高,数字的范围可以从 1 到 10^6000,因此我没有得到任何精度(使其成为最佳是另一个问题)。这是代码块:

for(int i=1; i<n+1; i++){
 // i is the integer value and bd is the value of the euler's number, so below i am multiplying the value of i with the euler's number
 BigDecimal x = BigDecimal.valueOf(i).multiply(bd);
 //Here i am taking floor of the above calculated value
 x.setScale(0, RoundingMode.HALF_UP);
 //and here sum is floor[1*euler's no] + floor[2*euler's number] + ... + floor[n*euler's number] 
 sum += x.intValue();
}

我想你是在问如何更精确地计算欧拉数(即 e)。

答案是实施一种快速收敛的算法。通过一些研究,我在 "Calculating the Value of e" 上找到了这个页面。最下面描述兄弟公式:

e =​ Sum(n=0, n=​∞​​​, (2n+2)​​ / (2n+1)!​​ )

收敛得非常快。您可以在 Java 中使用 BigDecimal 进行编码,以计算出您需要的任意位数精度。

另请参阅:

其中(如果我理解正确的话!)给出了一个收敛得更快的更复杂的公式。