Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 素性检验。这个程序的执行速度比所有其他程序都快吗? bool是素数(BigInt num) { 如果(num==0 | | num==1 | |(num!=2&&num%2==0)) 返回false; BigInt sq=sqrt(数值); 对于(BigInt i=3;i_C++_Performance_Primes - Fatal编程技术网

C++ 素性检验。这个程序的执行速度比所有其他程序都快吗? bool是素数(BigInt num) { 如果(num==0 | | num==1 | |(num!=2&&num%2==0)) 返回false; BigInt sq=sqrt(数值); 对于(BigInt i=3;i

C++ 素性检验。这个程序的执行速度比所有其他程序都快吗? bool是素数(BigInt num) { 如果(num==0 | | num==1 | |(num!=2&&num%2==0)) 返回false; BigInt sq=sqrt(数值); 对于(BigInt i=3;i,c++,performance,primes,C++,Performance,Primes,我有几天没有电脑了。你能告诉我结果吗 谢谢。 Praveen Kumar Sirohiwal 这个程序的执行速度比所有其他程序都快吗 否。 素性测试比审判分庭更快 例如: 另请参见:这取决于您测试的数字的大小。如果您测试32位整数,那么与其他方法相比,您的方法是合理有效的。如果您为RSA测试1024位整数,那么您的方法在整个宇宙的生命周期中将永远不会完成。@James K.Polk总裁1024位整数非常大。您确定吗是的,我确定。你可以阅读下面答案中的链接。 bool is_prime(Big

我有几天没有电脑了。你能告诉我结果吗

谢谢。
Praveen Kumar Sirohiwal

这个程序的执行速度比所有其他程序都快吗

否。

素性测试比审判分庭更快

例如:


另请参见:

这取决于您测试的数字的大小。如果您测试32位整数,那么与其他方法相比,您的方法是合理有效的。如果您为RSA测试1024位整数,那么您的方法在整个宇宙的生命周期中将永远不会完成。@James K.Polk总裁1024位整数非常大。您确定吗是的,我确定。你可以阅读下面答案中的链接。
bool is_prime(BigInt num)
{
    if(num == 0 || num == 1 || (num != 2 && num % 2 == 0))
        return false;

        BigInt sq = sqrt(num);

        for(BigInt i = 3; i <= sq; ++i, ++i)
            if(num % i == 0)
                 return false;

       return true;
}