Coded solution for prime().