它说在任何两个连续的自然数(n = 1,2,3,4,5,…)平方之间总是存在一个质数。这称为勒让德猜想。
猜想:猜想是基于不完整信息的命题或结论,该信息未找到证据,即尚未被证明或被证明。
Mathematically,
there is always one prime p in the range to where n is any natural number.
for examples-
2 and 3 are the primes in the range to .
5 and 7 are the primes in the range to .
11 and 13 are the primes in the range to .
17 and 19 are the primes in the range to .
例子:
Input : 4
output: Primes in the range 16 and 25 are:
17
19
23
说明:这里4 2 = 16和5 2 = 25
因此,介于16和25之间的质数是17、19和23。
Input : 10
Output: Primes in the range 100 and 121 are:
101
103
107
109
113
// CPP program to verify Legendre's Conjecture
// for a given n.
#include
using namespace std;
// prime checking
bool isprime(int n)
{
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
void LegendreConjecture(int n)
{
cout << "Primes in the range " << n * n
<< " and " << (n + 1) * (n + 1)
<< " are:" << endl;
for (int i = n * n; i <= ((n + 1) * (n + 1)); i++)
// searching for primes
if (isprime(i))
cout << i << endl;
}
// Driver program
int main()
{
int n = 50;
LegendreConjecture(n);
return 0;
}
输出:
Primes in the range 2500 and 2601 are:
2503
2521
2531
2539
2543
2549
2551
2557
2579
2591
2593
请参阅有关勒让德猜想的完整文章,以了解更多详细信息!
想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。