Pergunta de entrevista da empresa Infosys

Write code for prime number is optimized way?