Segmentation fault core dumped prime visits

hello @kartik-malik


declare ur both array of size 1000001.

and compute sieve upto 1000 000

still same error

a)
image
declare i as long long
b)
image
checck the formula.


corrected but still error

what error u r getting now?

/bin/run.sh: line 4: 17 Segmentation fault (core dumped) ./exe

declare both array as global and then try

miracle it worked but why

:joy::joy::joy::joy::joy:

no its not miracle , global scope has highe memory capacity than function scope .thats why it worked

1 Like

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.