Nth prime number

Given is that N<=5000000 then in my p[] what should the max size I can initialize so that all the N value is covered.

The size of your sieve array should be 100000001.

@S19APP-PP0108


can u check this even the console is not working.

Check out my code. It works for me. Plus its easy to understand.

N = 500000 how you have decide the array size required to generate the all the prime number <=number


if n = 5000000 then nothing happen?

We have to generate nth prime number. So checking the possible values of n, 500000 will accommodate all the prime numbers.

yes so we need to make an prime sieve which has actually 500000 pos where set bit is 1.
Then we need to make the another arrays which is actually contain the 500000 elements and onces that is formed we need to return the particualar nth values.?

@S19APP-PP0108 My question that In above ide link I am simple testing that how should I generate the primeSieve of such huge number 500000 . when I am trying to run for small number that is perfectly fine but for big number doesn’t show anything.

@S19APP-PP0108


here I have created the program to compute the nth prime number.
here i assume that max_size of the array is 100.
So suppose we have to generate total number of 500000 prime number so how should we decide the what will be the array size. for prime sieve array because we don’t know about that how much array size is required to generate the total nprime number.in case of arr[10] then 2,3,5,7 there are only 4 prime number. What is the approach here

For big number it doesn’t show anything because it lies outside the range of your sieve array. I suggest you to check out the code which I sent.

And the size of array which I used is working. So don’t worry about the rest. Just focus on the logic of the code.

@S19APP-PP0108 thanks

@Vikaspal Please mark your doubt as resolved now.