How much bigger array should I form to have 5000000 prime numbers and how am I suppose to know that ?
Deepak and primes
Hello @nalin1997,
In such cases, you are required to perform hit and trying method to find the best possible value for the size of your array.
You can consider the following while determining the size:
- The nth prime number is always greater than n. So, the size would surely be greater than 5000000.
- Start with the nearest power of two, 10000000.
If it doesn’t work, go for 10^8 and so on.
The rate of change would vary from question to question.
For this question,
#define N 100000007
this would work.
The second method is:
start learning the entire prime number series.
LOL, I am kidding. You need not do that.
It would be specified in the question itself.
Hope, this would help.
Give a like if you are satisfied.