Infosys interview question

Code for prime number