LTM Limited Interview Question

Approach of solving for prime number