Deepak and primes

please look into this problem of Deepak and primes
this code is working in other ide but in coding blocks ide its giving “/bin/run.sh: line 4: 18 Killed ./exe”

Hello @aman_81200 i have corrected your code:


if you have any doubt you can ask here:
Happy Learning!!

it was already working for small numbers
I need to find 5000000th prime number which is 86,028,121. so the number will be we need to find primes till 10^8
and the same code is working on


this compiler

@aman_81200 every online ide is not same they have constraints.
so i suggest you not to ask this question.
if you have any doubt like in submitting then i can surely help you.
and yes the method which you are suing can check prime numbers upto 1e8 only.
that method is not so optimised.

can you please guide me to the optimised approach

Sieve array requires you to store boolean data - true of false OR 1 or 0. Using int array would use up 8 times more space than required and that is a lot of wastage of space since we are making the sieve array of such a large size. Its possible some compiler won’t even allow you to make an array of so much space hence I suggested the modification.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.