Solution is correct?

I solved it using sieve , is it correct approach ?

@debyian hey ,yes seive is the correct approach for this question.