Infosys interview question

Write a program to find if the given number is a prime or not?(Optimized code)