Deepak and primes


Testcases are not passing and getting segmentation fault message.

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.

https://ide.codingblocks.com/s/200680
I added the vector but still getting fault

there are couple of small mistakes in your code

  1. size of array a is small, increase it and make the array global
  2. 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

@keshavgupta0103 code provided by you also not working

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.