solved problem 3 using Ruby primes library