Refactored java and scala code into the same place and created a proper PrimeCache object, solved p29