Exception for inappropriate values of $prime