Prime Generator Spoj

https://ide.codingblocks.com/s/336416 This code gets AC
but for m=99 , start=98 ,i-m=-1 and segment[-1] =1
Why this error didn’t come??

hello @Bhawna
your link is not working .
please save it to some other ide. and share the link

https://ide.geeksforgeeks.org/C3D5vo64As

some new compilers allow negative indices as well.
btw for which value of x,m ,n u r getting start = 98

m=99 ,x=2,n=144…

image
in place of this if
u can write
if x>=m or start < m
start=2*x;

no we cannot write like that as it will make start as 4 not 99

segreate that conditions into two if.

if x>=m
start=2*x

if start <m
start+=x

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.