Where am i going wrong in Deepak and Primes problem?
5000005 this is the size of my sieve. How it is not big enouth to store 5000000th prime number.
7,368,787 is the 5000000th prime number. I made changes according to this number in my code. Now it is throwing error.
@itismohiton that is not the 5,000,000th prime number, that is the 500,000th prime number. To overcome the issue of segmentation fault you can make your sieve a global variable (because stack has limited memory and global variables are not stored in the stack).
Can we do it using vector?
@itismohiton it is the same link please share the updates one. Yes you can use vectors also if you want.
I didn’t change array size, but made array as global. In the previous code it was throwing error but now it is not showing error but it is also not giving any output.
@itismohiton https://ide.codingblocks.com/s/232441 this is how you make it global (no need to pass it around in functions once its global, the whole point of making it global is to avoid using stack memory)
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.