Re-implement `nextPrimeInteger` predicate (#9281)