Hackerblock prime visit problem

i am getting segmentation fault for this code.Though I have applied the optimized approach by taken care of the given constraints

do some more changes

  1. declare “p” and “cum_sum” array globally

  2. The 500,000th prime is 7,368,787. so make size of array atleast 7400000

you can see the changes in modified Code

Modified Code

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like :heart:: and don’t forgot to mark doubt as resolved :grinning: