Solution to problem 49 & generic Prime class.