Runtime error in prime generator

CodeChef: Practical coding for everyone this is the link of my submission i have used segmented prime sieve.And its showing runtime error…
please help

First of all, seive is to be written in a separate function and to be called only once, it finds all prime numbers so that you save your time, you don’t need to check for each number if it is prime.

and your array is too small for the limits given in the question, it’ll definitely give a Segmentation Fault (SIGSEGV)

To check a number close to 10^9 you’ll need a sieve of size 10^9, which is not possible in C++. And you don’t need sieve to solve this problem, simple prime check function will work
Hoope this helps :slight_smile: