what should i keep my array length max since they can even ask 500000th prime number
much confusion in this
keeping high max crashes my code !! what to do in this case
what should i keep my array length max since they can even ask 500000th prime number
much confusion in this
keeping high max crashes my code !! what to do in this case
The 500,000th prime is 7,368,787.
so make size of array =74*10^5
this will not give segmentation fault
giving now alse segmentation…please do req change so that it runs 500000 in the ide above and check and tell the final thing please
changes Made
use bool array not long long int because you have to store only 0 or 1
use maxx=7400000
make size of aray =maxx+1 because you are accessing arr[maxx] which is valid only when size of array =maxx+1
Modified Code
if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with
and don’t forgot to mark doubt as resolved