Refactor the first prime index.