LTM Limited interview question

Write the optimal code for prime number in C++