It says that there is always one prime number between any two consecutive natural number’s(n = 1, 2, 3, 4, 5, …) square. This is called Legendre’s Conjecture.
Conjecture: A conjecture is a proposition or conclusion based upon incompleate information to which no proof has been found i.e it has not been proved or disproved.
Mathematically,
there is always one prime p in the rangeto
where n is any natural number.
for examples-
2 and 3 are the primes in the rangeto
.
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
.
Examples:
Input : 4
output: Primes in the range 16 and 25 are:
17
19
23
Explanation: Here 42 = 16 and 52 = 25
Hence, prime numbers between 16 and 25 are 17, 19 and 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 <bits/stdc++.h> 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
Please refer complete article on Legendre’s Conjecture for more details!
Recommended Posts:
- C Program for Program to find area of a circle
- C Program for Program for array rotation
- Lex Program to remove comments from C program
- Create Directory or Folder with C/C++ Program
- C Program to Swap two Numbers
- C Program for Bubble Sort on Linked List
- C program to Replace a word in a text by another given word
- C program to invert (making negative) an image content in PGM format
- C Program for Selection Sort
- C Program for Bubble Sort
- C Program for Insertion Sort
- C Program for Radix Sort
- C/C++ Program for n-th Fibonacci number
- C Program for Counting Sort
- C Program for Binary Search (Recursive and Iterative)
- C Program for Min Cost Path
- C/C++ Program for Longest Increasing Subsequence
- C Program for Pancake sorting
- C Program for Binary Insertion Sort
- C Program for Merge Sort

