Getting Segmantion Fault on compilation

Hi TA Support team,

I am getting segmentation fault error on compilation while I’m not accessing any unauthenticated memory space.
help to resolve the issue.

T

@Ayush487

  1. value of n can be upto 5000000 and size of your ans array is just 1000000. So for n>1000000, ans[n] doesn’t exist and it’ll give segmentation fault.
  2. Increase size of your sieve to 88000000. your sieve doesn’t have 5000000 prime numbers.