problem 10 + improved js isPrime() function