18 Segmentation Fault (core dumped)

Question: https://online.codingblocks.com/app/player/178555/content/173708/5057/code-challenge
My solution: https://ide.codingblocks.com/s/437522

Error message: /bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

Hello @mohaktrivedi the link which you have shared is not opening.
Tell me the question name.

Question name: Deepak and Primes

Hello @mohaktrivediyou are creating prime sieve everytime.
Just prepare it once and then give the output.Here I am attaching the corrected code Ide.codingblocks.com/s/437535

I’m calling it only once, so I’m creating Prime Sieve only once, right?

Tried running your code, it’s giving the exact same error.

Check this

It’s giving the same error again.

@tusharaggarwal272
I changed the data type of iterator from int to long long, and now I’m not getting that error.

However, I’m getting wrong answer for test case 3.
My solution: https://ide.codingblocks.com/s/437690

@mohaktrivedi code are passing test case when i am submitting:

Yes! This one works well for all the test cases. Thank you.
But, what exactly was causing the error in previous solutions of mine? Because to me it seems correct, did you find any mistakes in my latest solution?

@mohaktrivedi actually the last code was also passing all the test cases in mine.
all the codes which i have shared were passing test cases in mine.
so i am not sure why it was not passing on your side.

Alright. Yeah exactly, I see no issue in previous solutions. Anyway, thanks.

@mohaktrivedi
yes !
if you feel your query is cleared you can mark this as resolved.
Happy Learning!!

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.