Solved Problem 9, optimized isPrime

Refactor and class add!