Testcases are not passing and getting segmentation fault message.
Deepak and primes
hey @Rakshitgarg99 please use vector and push primes inside the vector and then print the number at n-1’th location, moreover your sieve is wrong please correct it.
there are couple of small mistakes in your code
- size of array a is small, increase it and make the array global
- your code of sieve is wrong in the second loop you need to compare j not i and in the first loop you should compare i * i, instead of i
correct code: https://ide.codingblocks.com/s/200737
hey @Rakshitgarg99 make sure you are submitting correct code as i checked again and code provided by me is passing all the test cases.
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.