相关疑难解决方法(0)

(e中的第一个10位素数).com python google Challenge 2004

我刚刚遇到了声称被谷歌 2004 年使用的挑战之一

(the first 10-digit prime in e).com 
Run Code Online (Sandbox Code Playgroud)

除此之外,我想接受挑战并用 python 解决它

>>> '%0.52f' % math.exp(1)
'2.71828182845904509079**5598298427**6488423347473144531250'
>>> '%0.52f' % numpy.exp(1)
'2.71828182845904509079**5598298427**6488423347473144531250'
Run Code Online (Sandbox Code Playgroud)

我的程序返回的5598298427是一个素数

上网查了一下,正确答案是7427466391

但是 python 中的 exp 数字不包括上面的数字

import numpy
import math

def prime(a):
    if a == 2: return True
    if a % 2 == 0: return False
    if a < 2: return False
    i = 2
    n = math.sqrt(a) + 1
    while(i < n):
        if a % i == 0:
            return False
        i += 1 …
Run Code Online (Sandbox Code Playgroud)

python math exp gmpy

5
推荐指数
1
解决办法
3262
查看次数

找到尽可能多的2的平方根数字

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
 double a = sqrt(2);
 cout << a << endl;
}
Run Code Online (Sandbox Code Playgroud)

嗨这是找到sqrt为2的程序,它在输出中只打印1.41421如何实现它的方式使得它将在小数点后打印200000位数

1.41421 ..........高达200 000位

有这样的印刷方法吗?

c++ sqrt

4
推荐指数
2
解决办法
4422
查看次数

代码一次生成一个数字

我试图建立一个恒定的随机数生成器(我的意思是一个RNG输出一系列不重复的数字,但每次从头开始都保持不变).我有一个pi.我需要一种算法来逐位生成e以馈入RNG,最好是以Python迭代器或生成器的形式.我也欢迎产生其他无理数的代码.提前致谢.

python algorithm math

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

标签 统计

math ×2

python ×2

algorithm ×1

c++ ×1

exp ×1

gmpy ×1

sqrt ×1