2 wrong testcase

@Aayush-Mahajan-2206170693038609
It is mentioned that N can be as large as 5000000 . If you look over the internet you can find that the 5000000th prime number is a little over 86 million. To be safe , I would suggest you to create a sieve of size 87 million.

When I made the for loop till 100000000 it’s giving runtime error

@Aayush-Mahajan-2206170693038609
It might be because 100 million is a bit too much. Since you are using long long int data type for the array and 100 million is a large size , the compiler may or may not be able to allocate such a large memory size for the array. Since we only need to store the information of true or false , you can use bool data type for the sieve array. This would save memory as bool requires lesser size than long long int. Also as I said 87 million is more than enough , so try that maybe . I’m not saying going up till 100 million is wrong but we have some compiler restrictions as well when it comes to such large arrays so try making a smaller array.

Yes I got the correct answer thanks for the help it worked with 10^8

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.