Prime Visits problem

Why I am getting segmentation fault ?

  1. you need to call sieve function only at once

  2. use long long int instead of int

  3. also make bool array instead of int array as you only need to stroe 0 and 1

Modified Code

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

What will be the time complexity of modified code ?

it is O(n*log(log(n));

for explanation see this i have recently solve this doubt

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