Prime visit ques


why in between 1 and 10 ,2 and 3 not get printed

and I try with C++ on spoj this quest it gives tle

I correct the code ==
but spoj still giving runtime error

https://www.spoj.com/submit/PRIME1/id=24256718 java

https://www.spoj.com/submit/PRIME1/id=24256920 c++

runtime error why?