Pergunta de entrevista da empresa Nasdaq

Technical question on finding prime numbers