solution for the next prime problem