Unable to understand the solution given in editorial

I am unable to understand the code given in editorial maybe it is written in c++,can you provide me a solution in java

Hii Vedant,
This question has to be done through sieve method so first see the video on sieve method and then try this question.

Hii Vedant

As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.