Pregunta de entrevista de Infosys

Write code for prime number is optimized way?