Morgan Stanley Interview Question

function to calc prime number