giving segmentation fault cant figure out where its going wrong
Deepak and primes 2 doubt
@rohit_1906
n and m have range long long
You’re using int so they are overflowing and probably become negative
that’s the issue
in my first attempt i did use long long , gave the same error , so i literally copied the same code from ‘segmented sieve’ video from the course content , giving same error
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc
/bin/run.sh: line 4: 18 Aborted (core dumped) ./exe
include, suggestion
showing this error
@rohit_1906
Line 5
int p[N+1]={0};
you did N instead of N+1
while in your sieve loop you’re going uptill N
okay did that , now the code aint printing any output for any input
@rohit_1906
I fixed an error for you buddy
So try to debug the next issue once
If you still face this issue after trying then let me know
I’ll be happy to help you out
It’s usually small errors only